but also you can use sed
sed -n 's/yes/&/p' file.txt>file2.txt
sed -n will output nothing unless the printing command is found (p). In this case sed will find those lines that contain "yes" and substitute them with the same string (&), i.e. there will be no substitute but it will print this line that is found in the output (p).
Output will be saved in file2.txt.
Nice tutorial on sed command: