Correctly check for end-of-word