It might work faster if you split the file into 26 smaller files, one for words starting with A, one for B, ...
And then find the first letter of the word your checking with $left and search the corresponding file.


A shotgun is always the answer.