Before proposing an approach, additional information is required:
Are you looking for just whole words or any substring?
Are you going to look for many different words in one unchanged file?
Do you know the words you want to find right away?
There are many efficient (linear) search algorithms for strings. If possible, I would suggest using one that has already been written for you.
http://en.wikipedia.org/wiki/String_searching_algorithm
One simple idea is to use a sliding window hash with a window of the same size as the search bar. Then, in one pass, you can quickly check where the window hash matches the hash of your search string. Where it fits, you double-check to see if you have a real match.
source share