Index: /branches/eam_branches/ipp-20120905/Ohana/src/libdvo/src/dvo_catalog_split.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 34691)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 34692)
@@ -83,4 +83,5 @@
     return (FALSE);
   }
+  off_t fullsize = catalog->header.datasize;
 
   // write the PHU matrix; this is probably a NOP, do I have to keep it in?
@@ -91,4 +92,5 @@
     return (FALSE);
   }
+  fullsize += matrix.datasize;
   gfits_free_matrix (&matrix);
 
@@ -98,4 +100,15 @@
     return (FALSE);
   }
+  fullsize += ftable->datasize + ftable->header->datasize;
+
+  // if the output file will be completely re-written, truncate to total datasize
+  if ((start == 0) && (Nrows == Ntotal)) {
+    int fd = fileno (catalog->f);
+    if (ftruncate (fd, fullsize)) {
+      perror ("dvo_catalog_save_subset: ");
+      return (FALSE);
+    }
+  }
+
   return (TRUE);
 }
Index: /branches/eam_branches/ipp-20120905/Ohana/src/libdvo/src/fits_db.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/libdvo/src/fits_db.c	(revision 34691)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/libdvo/src/fits_db.c	(revision 34692)
@@ -159,4 +159,10 @@
   make_backup (db[0].filename);
   Fseek (db[0].f, 0, SEEK_SET);
+
+  int fd = fileno (db->f);
+  if (ftruncate (fd, 0)) {
+    perror ("gfits_db_save: ");
+    return (FALSE);
+  }
 
   if (!gfits_fwrite_header  (db[0].f, &db[0].header)) {
