Fix writeout on failure