start reading from certain line

jstrick jstrick at
Thu Jul 10 15:45:47 CEST 2008

Here's a simple way to do it with a minimum amount of loopiness (don't
forget to use 'try-except' or 'with' in real life):

f = open("item1.txt")

for preline in f:
    if "Item 1" in preline:
        print preline,
        for goodline in f:
            # could put an end condition with a 'break' here
            print goodline,


More information about the Python-list mailing list