improve error message and keep temp file on failure