Corrected punctuation handling in program at end of words