for line in filtered_input:
    if 'silence.wav' in line:
        count = 0
else:
    count += 1
if count <= 2:
    filtered_output.write(line)
Issue with selecting multiple lines of a txt document and write to new text doc in python