Fix removal of file on failure