file access peek ahead
I need to read a file, line by line and I need to peek into 'the next line' so first I read the file into a list and then I cycle throught the list... somehow this seems rude, building the list could be become expensive.

    for line in open(filename, 'r'):
        lines.append(line[:-1])

    for cn in range(0, len(lines)):
        line = lines[cn]
        nextline = lines[cn+1] # actual code checks for this eof overflow

there must be a better way to iterate over the lines but I don't know how to peek ahead

file access peek ahead
===

I need to read a file, line by line and I need to peek into 'the next line' so first I read the file into a list and then I cycle throught the list... somehow this seems rude, building the list could be become expensive.

    for line in open(filename, 'r'):
        lines.append(line[:-1])

    for cn in range(0, len(lines)):
        line = lines[cn]
        nextline = lines[cn+1] # actual code checks for this eof overflow

there must be a better way to iterate over the lines but I don't know how to peek ahead
