Fixed an issue where duplicate words were being outputted.