Code Quiz

Lazy File Reader That Isn't Lazy

A generator meant to process a huge file line-by-line accidentally loads it all into memory.

Codepython
def read_large_file(path):
    with open(path) as f:
        lines = f.readlines()
    for line in lines:
        yield line.strip()

# Intended for multi-GB logs without blowing up RAM
for row in read_large_file('huge.log'):
    process(row)

This generator is supposed to stream a huge file with low memory usage. What is the bug?