I wanted to create a 10 files where each file has a "blob" word at the first sentence and read those sentence directly. Here's my code:
import random
import string
for i in range(9):
    name = input('fileNumber')+ str(i+1) + '.txt'
    try:
        file = open(name,'w+')
        file = open(name,'a')
        file.write("blob")
        file = open(name,'r')
        print file.read()       #'file' being highlighted with red color when I execute
        file.close()
When I run it, I got an error message saying Invalid syntax and it highlights my file.read() line.
Can somebody tell me where's the flaw in my code?
EDIT: I'm currently using python 3.5. However, I could also switch to 2.7 as well!