import speling errors = {} file = open('input.txt') for line in file: for word in line.split(): word = speling.clean_word(word) if speling.is_checkable_word(word): if not speling.dictionary_contains(word): errors[word] = errors.get(word, 0) + 1 file.close() wordlist = errors.keys() wordlist.sort() for word in wordlist: print '%s (%d)' % (word, errors[word])