#Author: James Tam #Version: October 30, 2024 #Learning objective: #*Reading the contents of an input file. #*Processing the information. #*Writing the processed informaiton to an output file. NEWLINE = "\n" inputFile = open("contact_list.txt","r") outputFile = open("contact_list_UPDATED.txt","w") #Number of file writes depends upon the number of lines in the input file i = 1 for line in inputFile: line = line.rstrip(NEWLINE) #Remove end of line modifiedLine = "Contact #" + str(i) + " " + line print("Original line: %s, Modified line: %s" %(line,modifiedLine)) outputFile.write(modifiedLine+NEWLINE) #Add back end of line i += 1 #Same as i = i + 1 inputFile.close() outputFile.close()