def _line_generator(fh):
    for line in fh:
        yield line.rstrip('\n')
Just remove linebreak characters and yield lines.
dataset/ETHPy150Open biocore/scikit-bio/skbio/io/format/phylip.py/_line_generator