Change the conditions for writing a file to disk to limit orphan files.

Signed-off-by: Martin Raspaud <martin.raspaud@smhi.se>