Searching for a string

If I want to read in a file and search each line for a certain string and then output every line that contains that string to a new file what is the best way to go about that?
Open input file
Open output file
Read line from input file
Compare to certain string
If match is found, write to output file
back to 3
Topic archived. No new replies allowed.