I want to write a program which filters the lines from my text file which contain the word "apple" and write those lines into a new text file.

What I have tried just writes the word "apple" in my new text file, whereas I want whole lines.