I am trying to write a program that opens a text document and replaces all four letter words with **. I have been messing around with this program for multiple hour
Here is a hint: len(words)
returns the number of words on the current line, not the length of any particular word. You need to add code that would look at every word on your line and decide whether it needs to be replaced.
Also, if the file is more complicated than a simple list of words (for example, if it contains punctuation characters that need to be preserved), it might be worth using a regular expression to do the job.