Store first in temporary file and rename to final destination
To make Midas safer and more user-friendly, we should store results first in a temporary file and move them to the final output file only when and if the computation finished successfully. Additionally, we can avoid overwriting existing files, giving the user to force this in case they are sure they want to replace existing files, for example for repeated testing.