In the toFile function. Fixed the not closing bug if this was intention
the this needs to be undone