--- 3rdparty/map2gcm/main.cpp	(revision 2783)
+++ 3rdparty/map2gcm/main.cpp	(working copy)
@@ -577,10 +579,9 @@
     zipfile.open(QIODevice::WriteOnly);
     QLGT::QZipWriter zip(&zipfile);
 
+    QByteArray doc;
 
-    FILE * fid      = fopen(KMLFILE,"w");
-    fprintf(fid,kmzHead);
-
+    doc.append(kmzHead);
     if(zip.status() != QLGT::QZipWriter::NoError)
     {
 
@@ -683,7 +684,7 @@
                         exit(-1);
                     }
 
-                    fprintf(fid, kmzOverlay, str, str, zorder, tile.top, tile.bottom, tile.right, tile.left);
+                    doc.append(QString(kmzOverlay).arg(str).arg(str).arg(zorder).arg(tile.top).arg(tile.bottom).arg(tile.right).arg(tile.left));
 
                     printf("\r    tile %i", tileCnt);
                     fflush(stdout);
@@ -696,19 +697,14 @@
         }
     }
 
-    fprintf(fid,kmzFoot);
-    fclose(fid);
 
-    QFile xml(KMLFILE);
-    xml.open(QIODevice::ReadOnly);
-    zip.addFile(KMLFILE, &xml);
+    doc.append(kmzFoot);
+    zip.addFile(KMLFILE, doc);
     if(zip.status() != QLGT::QZipWriter::NoError)
     {
         fprintf(stderr,"\nFailed to add file %s'' to KMZ\n", KMLFILE);
         exit(-1);
     }
-    xml.close();
-    xml.remove();
 
     printf("\n");
 
