You are calling the saveFile function every second, but it will crash if User isn’t assigned. I don’t know if this is the best fix, but you could try this:
saveFile
User