added a HashMap to keep track of the words used, with a printout at the end