in reply to subroutine to search a pattern in a file
Also see a similar program Online GREP problem.