Generate (yield) lines in a gzipped file (*.txt.gz) one line at a time

def generate_lines(input_file,
                   start=0,
                   stop=float('inf')):
    """Generate (yield) lines in a gzipped file (*.txt.gz) one line at a time"""
    with gzip.GzipFile(input_file, 'rU') as f:
        for i, line in enumerate(f):
            if i < start:
                continue
            if i >= stop:
                break
            yield line.rstrip()