in reply to Help with accepting inputs, wordcount, and print to a file

Alternative solution:No need to use multiple regexes to check for the words. This solution is very fast: checking for words in the whole of "Hamlet" took less than 1 second.

I have hidden my suggested solution in the "spoiler". First try it yourself and then check my solution.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics