Try reading chunks of the file, and processing them once they're in memory.

Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Interestingly, with optimisation turned off, your version runs about 8% faster than this version. However, with optimisation turned on this version runs about 215% faster than your version. I tested with a 'hot'(ie. a file that has been used several times and is therefore in the memory cache) 80MB file so real world results using 'cold' files may differ.

Thanks for all your help. After testing both versions of this code (mapping and my original). I noticed that my original way is a bit faster. There might be a bit of difference on slower machines between the two. Im going to test it on a few other machines. If anyone has any other suggestions then please post.