in reply to Counting instances of words
Others may give advice on coding style, I'm off to lunch.
Phil