This Says Invalid Syntax When There is None


#1


https://www.codecademy.com/courses/python-intermediate-en-OGNHh/0/3?curriculum_id=4f89dab3d788890003000096#

I put:
my_list = [i**2 for i in range(1,11)]

my_file = open("output.txt", "r+")

for x in my_list:
my_file.write('%s\n'%(str(x))
my_file.close()
It gives me a syntax error on the closing line. I think I'm doing it right, so why is this being so problematic?
The error:
Oops, try again. It looks like your syntax isn't quite right. Take a look at the example to the left or check the Hint if you need help.
File "python", line 8
my_file.close()
^
SyntaxError: invalid syntax


my_list = [i**2 for i in range(1,11)]

my_file = open("output.txt", "r+")

# Add your code below!
for x in my_list:
    my_file.write('%s\n'%(str(x))
my_file.close()


#2

)