Use regular File IO for the file with the names. Use Bio.Seq.IO for the FASTA file. Read all names into an array. Compare (either check for equality or use regular expressions) an appropriate attribute of the record read from the FASTA file to the set of names.If a match is found, print the record read from the FASTA file and move on to the next FASTA record. If you've scanned the entire set of names and you did not find a match, move on to the next record.
The approach above is vague on purpose. Also, you can optimize the approach in multiple ways, but this is one of the more basic approaches.
Can you show us what have you tried so far?