read from source file and write to target file line by line until the end of the source file. add the numbers in the source file and write to target file the sum.
def read_file_write_file(src_file, dst_file): with open(src_file, 'r') as src, open(dst_file, 'w') as dst: while True: line = src.readline() if not line: break dst.write(line) read_file_write_file('src.txt', 'dst.txt')