diff --git a/src/serial_io.c b/src/serial_io.c
index 05555f14a240b76710abcf573f20ea68f7bcc32f..e4b92e5d0d620a5298d5722f2bf47640ce6cf653 100644
--- a/src/serial_io.c
+++ b/src/serial_io.c
@@ -702,7 +702,7 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
     for (int ptype = 0; ptype < NUM_PARTICLE_TYPES; ptype++) {
 
       /* Don't do anything if no particle of this kind */
-      if (numParticles[ptype] == 0) continue;
+      if (N_total[ptype] == 0) continue;
 
       /* Open the particle group in the file */
       char partTypeGroupName[PARTICLE_GROUP_BUFFER_SIZE];
@@ -736,7 +736,7 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
       for (int ptype = 0; ptype < NUM_PARTICLE_TYPES; ptype++) {
 
 	/* Don't do anything if no particle of this kind */
-	if (N[ptype] == 0) continue;
+	if (N_total[ptype] == 0) continue;
 
 	/* Open the particle group in the file */
 	char partTypeGroupName[PARTICLE_GROUP_BUFFER_SIZE];