#Here is a program that #illustrates writing text #to a file, and reading #from a file. def read_write_files(): dir=pickAFolder() outfile=open(dir+"/"+"sample.txt","wt") outfile.write("Hello.") outfile.write("How are you?") outfile.write("\nGood to see you.") outfile.write("\nYes, I'm kind of a boring guy.") outfile.close() #Let's read from the file we just made in #two different ways. The first way reads #the file into one humongous string. The #second way reads the file one line at a #time and returns a list of strings. infile=open(dir+"/"+"sample.txt","rt") s=infile.read() infile.close() infile=open(dir+"/"+"sample.txt","rt") t=infile.readlines() infile.close() print "s:",s print "t:",t