So walk through the text - but use the variable inWord, and your count will be correct in ALL cases. You increment a word ONLY when inWord is 1, and you reach a non alphanumeric char.
You can't just count spaces - that will fail, and you can't make it NOT fail, without a variable like inWord.