diff --git a/src/ChangeLog b/src/ChangeLog
index 6ffdb2c0..10554461 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2005-05-17  Hrvoje Niksic  <hniksic@xemacs.org>
+
+	* http.c (http_loop): Don't clobber the file when -c is specified
+	and the first attempt to retrieve the file fails.
+
 2005-05-16  Hrvoje Niksic  <hniksic@xemacs.org>
 
 	* openssl.c (ssl_check_certificate): Print all issues with a
diff --git a/src/http.c b/src/http.c
index 3a2f908e..d549012c 100644
--- a/src/http.c
+++ b/src/http.c
@@ -2141,13 +2141,18 @@ File `%s' already there, will not retrieve.\n"), *hstat.local_file);
 	*dt &= ~HEAD_ONLY;
 
       /* Decide whether or not to restart.  */
-      hstat.restval = 0;
-      if (count > 1)
-	hstat.restval = hstat.len; /* continue where we left off */
-      else if (opt.always_rest
-	       && stat (locf, &st) == 0
-	       && S_ISREG (st.st_mode))
+      if (opt.always_rest
+	  && stat (locf, &st) == 0
+	  && S_ISREG (st.st_mode))
+	/* When -c is used, continue from on-disk size.  (Can't use
+	   hstat.len even if count>1 because we don't want a failed
+	   first attempt to clobber existing data.)  */
 	hstat.restval = st.st_size;
+      else if (count > 1)
+	/* otherwise, continue where the previous try left off */
+	hstat.restval = hstat.len;
+      else
+	hstat.restval = 0;
 
       /* Decide whether to send the no-cache directive.  We send it in
 	 two cases: