# Filecopy.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-14 File created. # 2022-12-18 Converted to Python 3. print( "\n This program copies text from one file" \ "\n to another file. Please, give the name of" \ "\n the file to be copied: ", end="" ) name_of_file_to_be_copied = input() print( "\n Give the name of the duplicate file: ", end="" ) name_of_new_duplicate_file = input() file_to_be_copied = open( name_of_file_to_be_copied, 'r' ) new_duplicate_file = open( name_of_new_duplicate_file, 'w' ) print( "\n Copying in progress ... " ) text_line_counter = 0 end_of_input_file_encountered = False while end_of_input_file_encountered == False : text_line_from_file = file_to_be_copied.readline() if text_line_from_file == "" : end_of_input_file_encountered = True else : new_duplicate_file.write( text_line_from_file ) text_line_counter += 1 print( "\n Copying ready. %d lines were copied. " % text_line_counter ) file_to_be_copied.close() new_duplicate_file.close()