diff --git a/src/write_data.cpp b/src/write_data.cpp
index bf00249e51f2ba13c91b7f9616991b0c293d3f3a..7c8838628eb482f298c20046a40f8f0bab514a30 100644
--- a/src/write_data.cpp
+++ b/src/write_data.cpp
@@ -243,11 +243,11 @@ void WriteData::header()
       fprintf(fp,"%d angle types\n",atom->nangletypes);
     }
     if (atom->ndihedrals || atom->ndihedraltypes) {
-      fprintf(fp,BIGINT_FORMAT " dihedrals\n",atom->ndihedrals);
+      fprintf(fp,BIGINT_FORMAT " dihedrals\n",ndihedrals);
       fprintf(fp,"%d dihedral types\n",atom->ndihedraltypes);
     }
     if (atom->nimpropers || atom->nimpropertypes) {
-      fprintf(fp,BIGINT_FORMAT " impropers\n",atom->nimpropers);
+      fprintf(fp,BIGINT_FORMAT " impropers\n",nimpropers);
       fprintf(fp,"%d improper types\n",atom->nimpropertypes);
     }
   }