has_small_string = False
for line in large_file:
    if small_string in line:
        has_small_string = True
break
if has_small_string:
    pass
Python efficient way to check if very large string contains a substring