For the program I am trying to design, I am checking that certain conditions exist in configuration files. For example, that the line: **ThisExists** is in the program, or that **ThisIsFirst** exists in the file followed by **ThisAlsoExists** somewhere later down in the file.

I looked for an efficient approach which might be used in this situation but couldn't find any.

My current idea is basically to just iterate over the file(s) multiple times each time I want to check a condition. So I would have functions:

def checkA(file)

def checkB(file)

.
.
.

To me this seems inefficient as I have to iterate for every condition I want to check.

Initially I thought I could just iterate once, checking each line for every condition I want to verify. But I don't think I can do that as conditions which can be multi line require information about more than one line at a time.

Is the way I outlined the only way to do this, or is there a more efficient approach? 

I am trying to provide an example below.

```
def main():
    file = open(filename)
    result1 = checkA(file)
    result2 = checkB(file)

    """This is a single line check function"""
    def checkA(file)
        conditionExists = False
        for line in file:
            if(line == "SomeCondition"):
                 conditionExists = True
         return conditionExists

    """This is a multi line check function"""
    def checkB(file)
        conditionExists = False
        conditionStarted = False
        for line in file:
             if(line == "Start"):
                 conditionStarted = True
             elif(line == "End" and conditionStarted):
                  conditionExists = True
        return conditionExists

```