I'm just trying to create a program that will remove all the trailing whitespace in a text file.
(Like all the whitespace after each sentence for the whole text file.)

n = raw_input("Enter name of file: ")

f = file(n, "r")
fr = f.read()

for fr in f:
    fr = fr.rstrip()

f.close()
print fr

The problem I have is after I did the rstrip(), nothing really happened to the text file? I don't really know what I'm missing.

Sorry, double post.

The problem I have is after I did the rstrip(), nothing really happened to the text file? I don't really know what I'm missing.

You have to write the data to a file. You read the disk file into memory, change it in memory and then exit the program. If you want the file in memory saved to disk, then use "write" in addition to "read". http://www.greenteapress.com/thinkpython/thinkCSpy/html/chap11.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.