Have a look at the following example. Suppose my test.txt file has the following content and it's a dynamic file.
abcdefghijklmno324q232345322345325
and I want my code to perform some operation if it sees '12345' in the input file.
found=0f=open('test.txt' ,'r')while not found: cp = f.tell() line = f.readline() if not line.strip(): f.seek(cp) elif '123456' in line: print(line.strip()) #do something