diff --git a/compiler/main.lisp b/compiler/main.lisp
index b0812f4dafce4dcc91c1130a3a2f3fcf6b3e6006..61a78c02ba6d1a6040e8d0ec2d84363b07b1f79c 100644
--- a/compiler/main.lisp
+++ b/compiler/main.lisp
@@ -1000,7 +1000,7 @@
       (when error-file-stream
 	(let ((name (pathname error-file-stream)))
 	  (close error-file-stream)
-	  (unless error-severity
+	  (when (and compile-won (not error-severity))
 	    (delete-file name))))
 
       (when *compiler-trace-output*