For just getting the first or last lines in a file, head and tail are far more straightforward.
e.g. head -5 [filename] | grep [words]
You can play all kinds of lovely games with grep, sed and awk. So much so they wrote a nice O'Reilly book about them.
e.g. grep can output X many lines before and Y many lines after the match with -A and -B so you can look for strings in lines adjacent to matches etc...
I run my own mailserver, and let any address come in, so when I give emails I can make them up on the fly (company name) so I can track spam. I run this periodically on my Spam folder:
To check for any personal emails that got caught. It shows me any unique subjects (so it filters the 100 vi@gra spams I have) that came to my personal address so I can quickly scan for somebody that sent me an message that got binned wrongly. Cuts out an incredible amount of chaff.