Python program to write list into csv file and read back into list from 'csv' file

######################################################
Python program to write list into csv file and read back into list from 'csv' file
######################################################

Code : 

import csv
outputFile = open('output.csv', 'w', newline='')
outputWriter = csv.writer(outputFile)
outputWriter.writerow(['spam', 'eggs', 'bacon', 'ham'])
outputWriter.writerow(['Hello, world!', 'eggs', 'bacon', 'ham'])
outputWriter.writerow([1, 2, 3.141592, 4])
outputFile.close()


exampleFile = open('output.csv')
exampleReader = csv.reader(exampleFile)
print('###########################################################')
for row in exampleReader:
  print('Row #' + str(exampleReader.line_num) + ' ' + str(row))

print('###########################################################\n')

Output :

###########################################################
Row #1 ['spam', 'eggs', 'bacon', 'ham']
Row #2 ['Hello, world!', 'eggs', 'bacon', 'ham']
Row #3 ['1', '2', '3.141592', '4']
###########################################################