Index: trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java	(revision 868)
+++ trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java	(revision 872)
@@ -129,5 +129,8 @@
 		// TODO: add copyright, etc.
 		try {
-			new GpxWriter(new FileOutputStream(file)).write(gpxData);
+			FileOutputStream fo = new FileOutputStream(file);
+			new GpxWriter(fo).write(gpxData);
+			fo.flush();
+			fo.close();
 		} catch (IOException x) {
 			x.printStackTrace();
Index: trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java	(revision 868)
+++ trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java	(revision 872)
@@ -186,6 +186,9 @@
 					copy(file, tmpFile);
 				}
-
-				new GpxWriter(new FileOutputStream(file)).write(layer.data);
+				FileOutputStream fo = new FileOutputStream(file);
+				new GpxWriter(fo).write(layer.data);
+				fo.flush();
+				fo.close();
+
 				if (!Main.pref.getBoolean("save.keepbackup") && (tmpFile != null)) {
 					tmpFile.delete();
Index: trunk/src/org/openstreetmap/josm/io/GpxWriter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxWriter.java	(revision 868)
+++ trunk/src/org/openstreetmap/josm/io/GpxWriter.java	(revision 872)
@@ -51,5 +51,4 @@
 		out.print("</gpx>");
 		out.flush();
-		out.close();
 	}
 
