read from source file one line at a time and write to target file one line at time.
def copy(source, target): source_f = open(source) target_f = open(target, 'w') while True: line = source_f.readline() if len(line) == 0: break target_f.write(line) source_f.close() target_f.close() copy('source.txt', 'target.txt')