This problem involves reading in a text file of words in the…