I am trying to write a program which finds all anagrams (words that are remade by rearranging their letters) in the dictionary (/usr/share/dict/words file in Linux). The dictionary file contains a lot of words that ends with " 's " which I want to exclude from checking. Here is what I wrote to do that, but unfortunately the result file contains lines with just one letter "s" I have no idea where it comes from. I am trying to write a program which finds all