Refined code for speed

Trying to speed up the code so I can feed in huge text files like the
Bible.