# writin content of one file to the other with open("source.txt", "r") as inFile, open("target.txt", "w") as outFile: for line in inFile: print(line.strip(" "), file=outFile)