grep syntax issue on Lion
Its usually because of a DOS formatted text file (CRLF). To clean the file you can install a tooö like dos2unix; but usually works even simpler by using the tr tool:

tr -d '\r' &lt; testfile &gt; output.txt