diff --git a/src/common_io.c b/src/common_io.c
index 43119ee82e406df3efd269426117912488e2b15f..fad18b32d1e5b01a7c7086a5d4bf6236c64c59b4 100644
--- a/src/common_io.c
+++ b/src/common_io.c
@@ -805,8 +805,9 @@ void io_collect_dm_gparts(const struct gpart* const gparts, size_t Ntot,
     /* message("i=%zd count=%zd id=%lld part=%p", i, count, gparts[i].id,
      * gparts[i].part); */
 
-    /* And collect the DM ones */
-    if (gparts[i].type == swift_type_dark_matter) {
+    /* And collect the DM ones that have not been removed */
+    if (gparts[i].type == swift_type_dark_matter && 
+	gparts[i].time_bin != time_bin_inhibited) {
       dmparts[count] = gparts[i];
       count++;
     }
diff --git a/src/single_io.c b/src/single_io.c
index 764d58cf7411e58a10b6003edf0b4d3a9d5caef7..a745e66ef7c9a96efe9aa94105037bb92c81755d 100644
--- a/src/single_io.c
+++ b/src/single_io.c
@@ -603,15 +603,14 @@ void write_output_single(struct engine* e, const char* baseName,
                          const struct unit_system* snapshot_units) {
 
   hid_t h_file = 0, h_grp = 0;
-  const size_t Ngas = e->s->nr_parts;
-  const size_t Nstars = e->s->nr_sparts;
-  const size_t Ntot = e->s->nr_gparts;
+  const size_t Ngas = e->total_nr_parts - e->nr_inhibited_parts;
+  const size_t Nstars = e->total_nr_sparts - e->nr_inhibited_sparts;
+  const size_t Ntot = e->total_nr_gparts - e->nr_inhibited_gparts;
   int periodic = e->s->periodic;
   int numFiles = 1;
   const struct part* parts = e->s->parts;
   const struct xpart* xparts = e->s->xparts;
   const struct gpart* gparts = e->s->gparts;
-  struct gpart* dmparts = NULL;
   const struct spart* sparts = e->s->sparts;
   const struct cooling_function_data* cooling = e->cooling_func;
   struct swift_params* params = e->parameter_file;
@@ -828,6 +827,8 @@ void write_output_single(struct engine* e, const char* baseName,
     struct io_props list[100];
     size_t N = 0;
 
+    struct gpart* dmparts = NULL;
+  
     /* Write particle fields from the particle structure */
     switch (ptype) {
 
@@ -846,7 +847,7 @@ void write_output_single(struct engine* e, const char* baseName,
           error("Error while allocating temporart memory for DM particles");
         bzero(dmparts, Ndm * sizeof(struct gpart));
 
-        /* Collect the DM particles from gpart */
+        /* Collect the non-inhibited DM particles from gpart */
         io_collect_dm_gparts(gparts, Ntot, dmparts, Ndm);
 
         /* Write DM particles */