Index: applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveEditLayerTimerTask.java
===================================================================
--- applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveEditLayerTimerTask.java	(revision 3262)
+++ applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveEditLayerTimerTask.java	(revision 3275)
@@ -44,12 +44,16 @@
             DataSet dataset = layer.data;
 
-            File outFile = layer.associatedFile;
-            if(outFile == null) {
-                outFile = file;
+//            File outFile = layer.associatedFile;
+//            if(outFile == null) {
+//                outFile = file;
+//            }
+            
+            // write to temporary file, on success, rename tmp file to target file:
+            File tmpFile = new File(file.getAbsoluteFile()+".tmp");
+            System.out.println("AutoSaving osm data to file " + file.getAbsolutePath());
+            synchronized(LiveGpsLock.class) {
+                XmlWriter.output(new FileOutputStream(tmpFile), new OsmWriter.All(dataset, false));
             }
-            System.out.println("AutoSaving osm data to file " + outFile.getAbsolutePath());
-            synchronized(LiveGpsLock.class) {
-                XmlWriter.output(new FileOutputStream(outFile), new OsmWriter.All(dataset, false));
-            }
+            tmpFile.renameTo(file);
             System.out.println("AutoSaving finished");
         } catch (IOException x) {
