refactor count words of each length in file