diff --git a/modules/io/src/mol/mmcif_writer.cc b/modules/io/src/mol/mmcif_writer.cc
index 158f17fdc8c57d3dcddcb4ea0e0067a390cb5b2c..e944bf9a2b2384066d20a38b08132d15f8a45751 100644
--- a/modules/io/src/mol/mmcif_writer.cc
+++ b/modules/io/src/mol/mmcif_writer.cc
@@ -987,6 +987,9 @@ namespace {
     std::set<String> unique_compounds;
     for(auto ent: entity_infos) {
       unique_compounds.insert(ent.mon_ids.begin(), ent.mon_ids.end());
+      for(auto het_it: ent.het) {
+        unique_compounds.insert(het_it.second.begin(), het_it.second.end());
+      }
     }
     std::vector<ost::io::StarWriterValue> comp_data(2);
     for(auto mon_id: unique_compounds) {