grep version

$ grep --version
grep (GNU grep) 2.14
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

Stray characters in F1.txt?

While debugging this further I noticed several stray spaces at the end of the 2nd line in the file F1.txt. You can see them using hexdump.

grep --version GNU grep 2.6.3 Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <gnu.org/licenses/gpl.html&gt; This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. I am only getting the matches if they exist as individuals and not as you said.Strangely,The only match I am getting is the last pattern from the file containing the patterns to be matched.
–
RonFeb 14 '14 at 21:29

I have pasted more complete version of my second file although with less rows,and tried searching for it.It does not match the second row from second file
–
RonFeb 14 '14 at 21:39

@Ron - You have stray characters at the end of the strings in the F1.txt file that's causing your issue. Just confirmed it works fine on grep (GNU grep) 2.5.1
–
slm♦Feb 14 '14 at 21:50

okay.I saw those characters now.how should I remove these characters then? using tr?
–
RonFeb 14 '14 at 22:00

I just saved the file in text wrangler in Unix-LF format,and now it works!!
–
RonFeb 14 '14 at 22:17