code: ```py
import csv
def read_file(filename):
try:
with open(filename, "r", newline="") as f1:
return f1
except FileNotFoundError:
print("File not found")
return None
def print_averages(fileobj):
if fileobj is None:
return
a = csv.reader(fileobj)
next(a) # Skip header row
collection_of_grades = []
for i in a:
for j in range(len(i)):
if j in (1, 2, 3): # Check if the column index is 1, 2, or 3
collection_of_grades.append(float(i[j]))
avg = sum(collection_of_grades) / len(collection_of_grades)
print("Average grade:", avg)
filename = r"C:\Users\blufl\OneDrive\Desktop\CMPT120\Actual code\grades.csv"
def main(filename):
fileobj = read_file(filename)
if fileobj:
print_averages(fileobj)
else:
print("Unable to open file:", filename)
main(filename)
Error message: ```Exception has occurred: ValueError
I/O operation on closed file.
File "C:\Users\blufl\OneDrive\Desktop\CMPT120\Actual code\lab7p1.py", line 15, in print_averages
a = csv.reader(fileobj)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\blufl\OneDrive\Desktop\CMPT120\Actual code\lab7p1.py", line 31, in main
print_averages(fileobj)
File "C:\Users\blufl\OneDrive\Desktop\CMPT120\Actual code\lab7p1.py", line 35, in <module>
main(filename)
ValueError: I/O operation on closed file.```