import sys filename = 'letters.txt' mode = 'r' # read mode # Step 1) Open the file # Step 2) Verify successful file open try: inputFileObj = open( filename, mode ) # Step 3) Read from or write to the file # Read all of the lines from the file and put them into a list listOfLines = inputFileObj.readlines() except: print('ERROR! Unable to open or read from', filename) sys.exit() # Step 4) Close the file inputFileObj.close() # loop through each line # display each line (which includes the newline) counter = 1 for line in listOfLines: print(f'Line #{counter:02}: {line}', end='') counter += 1