read from one file and write to another file line by line until end of file
def read_write_file(read_file, write_file): data = open(read_file, 'r') data_to_write = open(write_file, 'a') for line in data: if '\n' in line: line = line[:-1] data_to_write.write(line + '\n') data.close() data_to_write.close() read_write_file('some_file', 'some_new_file')