Grep does what you want it to do ... which is to only output lines which match the pattern(s). The problem (I suspect) is that you may have a blank line in your patterns file, which grep matches against all lines in your data file.
Once you remove the blank line you will only get matching lines in the output.
Also, I wasn't clear if you wanted to get the full lines in your output, or only the portion of each line that matched a pattern. If the latter then use the -o flag:
Print only the matched (non-empty) parts of a matching
line, with each such part on a separate output line.