Is there some reason you aren't using grep(1)?
duff
In reply to Re: Reading lines and matching words by duff in thread Reading lines and matching words by mantra2006