Fixed Bug with nextWord()

Fixed the bug that broke the nextWord() method when the next word is at
the end of the string. Works correctly now