Why Can't USACO read my Python files

Hi, I was wondering why Python on USACO cannot read my files. Is it because the formatting for my read input and output are wrong. Can somebody please tell me what is wrong. I have attached a sample code below. Thanks.
if name == ‘main’:
fin = open(‘word.in’, ‘r’)
fout = open(‘word.out’, ‘w’)

n, y = map(int, fin.readline().strip().split())
coo = fin.readline().strip().split()

subs = “”
i = 0
lent = 0
for i in range(n):
lent += len(coo[i])

if (lent <= y):
  subs += (coo[i]+" ")    

else:
  #print(subs)
  fout.write(subs + "\n")
  subs=(coo[i]+" ")
  lent = 0
  lent += len(coo[i])

#print (subs)
fout.write(subs)
fout.close()

Please format your code correctly before asking for help.

Hi, I was wondering why Python on USACO cannot read my files. Is it because the formatting for my read input and output are wrong. Can somebody please tell me what is wrong. I have attached an image of the problem and the sample code below. Thanks.

import sys
sys.stdin = open("word.in", "r")
sys.stdout = open("word.out", "w")


n,y = map(int, input().split())
coo = input().split()

  
subs = ""
i = 0
lent = 0
for i in range(n):
  lent += len(coo[i])
  if (lent <= y):
    subs += (coo[i]+" ")    
    
  else:
    print(subs)
    
    subs=(coo[i]+" ")
    lent = 0
    lent += len(coo[i])
      
print (subs)

You seem to be missing a newline or have an extra newline. I can’t say for sure.

Agreed. Probably something wrong with the whitespaces, as this should work fine…