SyntaxFix
Write A Post
Hire A Developer
Questions
Just iterate over each line in the file. Python automatically checks for the End of file and closes the file for you (using the with syntax).
with
with open('fileName', 'r') as f: for line in f: if 'str' in line: break