SO i have to read in this list of fruits text doc and then I have to write it out to another text doc but this time all the fruits need to be in alphabetical order. I have gotten all this done. I even print the list and its all in order. The problem is that when I tell it to write it to the new text doc it just prints the last word. I dont know if its the command that i have wrong or a logical error. Someone please help!!!!!
This is the code everything is straightforward i even tried the indenting but i just cant get it to put the right information in the text doc although i print the list right before and its perfect.
fileIn = open ("listOfFruits.txt", "r") fileOut = open ("newListOfFruits.txt", "w") line =  for currentLine in fileIn: currentLine.split(" ") line.append(currentLine) for word in line: line.sort() fileOut.write(word) ##print line fileIn.close() fileOut.close()