def line_joiner(line_iterator):
    """    Given a readline function, return lines, but handle line continuations
    ('\\
'). When lines are joined, the same number of blank lines is output
    so that the line counter for the consumer stays correct.
    """
    while True:
        joined_line = '\\\n'
        joined_lines = 0
        while joined_line[-2:] == '\\\n':
            joined_line = joined_line[:-2]
            line = next(line_iterator)
            if not line:
                break
            joined_line += line.rstrip() + '\n'
            joined_lines += 1
        while joined_lines > 1:
            yield '\n'
            joined_lines -= 1
        if not joined_line:
            break
        yield joined_line
