Fixed bug where it was trying to create a file more than once