read from source file one line at a time and write to target file one line at time.
def readFile(filename, targetFile): f = open(filename, "r") t = open(targetFile, "w") for l in f.readlines(): t.write(l) f.close t.close readFile("sample.txt", "target.txt")