Fix incorrect word ending determination.