def readline_iterator(f):
    """iterate over a file by only using the file object's readline method"""
    have_newline = False
    while True:
        line = f.readline()
        if not line:
            if have_newline:
                yield ''
            return
        if line.endswith('\n'):
            have_newline = True
        else:
            have_newline = False
        yield line
