b017d54a382f598a4ac158e20e3336d359d1d55d
diff --git a/libsoup/soup-cookie-jar-text.c b/libsoup/soup-cookie-jar-text.c
index 7fae6e1..52ad12c 100644
--- a/libsoup/soup-cookie-jar-text.c
+++ b/libsoup/soup-cookie-jar-text.c
@@ -44,7 +44,6 @@ typedef struct {
 G_DEFINE_TYPE (SoupCookieJarText, soup_cookie_jar_text, SOUP_TYPE_COOKIE_JAR)
 
 static void load    (SoupCookieJar *jar);
-static void save    (SoupCookieJar *jar);
 static void changed (SoupCookieJar *jar,
 		     SoupCookie    *old_cookie,
 		     SoupCookie    *new_cookie);
@@ -79,7 +78,6 @@ soup_cookie_jar_text_class_init (SoupCookieJarTextClass *text_class)
 
 	g_type_class_add_private (text_class, sizeof (SoupCookieJarTextPrivate));
 
-	cookie_jar_class->save    = save;
 	cookie_jar_class->changed = changed;
 
 	object_class->finalize     = finalize;
@@ -152,8 +150,8 @@ get_property (GObject *object, guint prop_id,
  *
  * If @filename is non-%NULL, it will be read in at startup to create
  * an initial set of cookies. If @filename is non-%NULL and @read_only
- * is %FALSE, then calls to soup_cookie_jar_save() will write out
- * the current state of the cookie jar to that file. (If @filename is
+ * is %FALSE, then the non-session cookies will be written to @filename
+ * when the 'changed' signal is emmitted from the jar. (If @filename is
  * %NULL and/or @read_only is %TRUE, then the cookie jar will only be
  * used for this session, and changes made to it will be lost when the
  * jar is destroyed.)
@@ -342,12 +340,24 @@ changed (SoupCookieJar *jar,
 		delete_cookie (priv->filename, old_cookie);
 
 	if (new_cookie) {
+		gboolean write_header = FALSE;
+
+		if (!g_file_test (priv->filename, G_FILE_TEST_EXISTS))
+			write_header = TRUE;
+
 		out = fopen (priv->filename, "a");
 		if (!out) {
 			/* FIXME: error? */
 			return;
 		}
 
+		if (write_header) {
+			fprintf (out, "# HTTP Cookie File\n");
+			fprintf (out, "# http://www.netscape.com/newsref/std/cookie_spec.html\n");
+			fprintf (out, "# This is a generated file!  Do not edit.\n");
+			fprintf (out, "# To delete cookies, use the Cookie Manager.\n\n");
+		}
+
 		if (new_cookie->expires)
 			write_cookie (out, new_cookie);
 
@@ -357,47 +367,3 @@ changed (SoupCookieJar *jar,
 		}
 	}
 }
-
-static void
-save (SoupCookieJar *jar)
-{
-	SoupCookieJarTextPrivate *priv =
-		SOUP_COOKIE_JAR_TEXT_GET_PRIVATE (jar);
-	GSList *cookies, *c;
-	char *tmpfile;
-	FILE *out;
-
-	if (priv->read_only || !priv->filename)
-		return;		
-
-	tmpfile = g_strdup_printf ("%s.tmp", priv->filename);
-	out = fopen (tmpfile, "w");
-	if (!out) {
-		/* FIXME: error? */
-		g_free (tmpfile);
-		return;
-	}
-
-	fprintf (out, "# HTTP Cookie File\n");
-	fprintf (out, "# http://www.netscape.com/newsref/std/cookie_spec.html\n");
-	fprintf (out, "# This is a generated file!  Do not edit.\n");
-	fprintf (out, "# To delete cookies, use the Cookie Manager.\n\n");
-
-	cookies = soup_cookie_jar_all_cookies (jar);
-
-	/* FIXME: order? */
-	for (c = cookies; c; c = c->next) {
-		SoupCookie *cookie = c->data;
-		write_cookie (out, cookie);
-	}
-	g_slist_free (cookies);
-
-	if (fclose (out) != 0) {
-		/* FIXME: error? */
-		g_free (tmpfile);
-		return;
-	}
-
-	rename (tmpfile, priv->filename);
-	g_free (tmpfile);
-}
diff --git a/libsoup/soup-cookie-jar.c b/libsoup/soup-cookie-jar.c
index 9af0560..08e0133 100644
--- a/libsoup/soup-cookie-jar.c
+++ b/libsoup/soup-cookie-jar.c
@@ -135,8 +135,7 @@ soup_cookie_jar_new (void)
 void
 soup_cookie_jar_save (SoupCookieJar *jar)
 {
-	if (SOUP_COOKIE_JAR_GET_CLASS (jar)->save)
-		SOUP_COOKIE_JAR_GET_CLASS (jar)->save (jar);
+	/* Does nothing, obsolete */
 }
 
 /**
diff --git a/libsoup/soup-cookie-jar.h b/libsoup/soup-cookie-jar.h
index 28af619..18114fd 100644
--- a/libsoup/soup-cookie-jar.h
+++ b/libsoup/soup-cookie-jar.h
@@ -53,6 +53,7 @@ void           soup_cookie_jar_delete_cookie (SoupCookieJar *jar,
 					      SoupCookie    *cookie);
 GSList        *soup_cookie_jar_all_cookies   (SoupCookieJar *jar);
 
+
 G_END_DECLS
 
 #endif /* SOUP_COOKIE_JAR_H */
