Question: ```
def openFood():
    with open("FoodList.txt")  as f:
                lines = f.readlines()
                for line in lines:
                    if 'Food' in line:
                        print(f.next())
openFood()

```

I want it where when it sees a certain header like 'Food' It will print the line below it. I cant seem to make it work. The text file will be like

```
Food
Apple
Cal 120
Protein 12
Fat 13 
Carb 23

```

Answer: 
Just use the index.

```
def openFood():
    with open("FoodList.txt")  as f:
        lines = f.readlines()
        for i in range(len(lines)-1):
            if 'Food' in lines[i]:
                print(lines[i+1])
openFood()

```
`readlines()` reads all the lines in a file and returns a list. You could either read and iterate one line at a time (using `readline()`), or read all the lines and use the list for iteration (using `readlines()`).

Apart from the ways mentioned, you could also use a `bool` like below (I've used `readlines()` here):

```py
def openFood():
    with open("FoodList.txt")  as f:
        lines = f.readlines()
        trigger = "Food"
        triggerfound = False

        for line in lines:
            if triggerfound:
                print(line)
                triggerfound = False

            if trigger in line:
                triggerfound = True

openFood()

```