in reply to Should this be so slow ?

You're not helping yourself in any way by reading the whole file into memory. It's not clear from your code how you expect to re-use the lines you've read in. The foreach loop will walk through them and they'll be released.

I'd say read your config file, figure out all the files you're going to have to search and all the terms you're going to have to search for, then read the files line-by-line and do all your searches on each line as you go.


Caution: Contents may have been coded under pressure.