Fix bug where file does not get written if not created