diff --git a/src/ModFile.cc b/src/ModFile.cc
index 788801cd1b5770080aeb0f63cd4d789c673b7175..7aafd3004ad793e7fb7f68bca15b033a604efca0 100644
--- a/src/ModFile.cc
+++ b/src/ModFile.cc
@@ -868,6 +868,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
 
   symbol_table.writeOutput(mOutputFile);
 
+  var_model_table.writeOutput(mOutputFile);
   trend_component_model_table.writeOutput(mOutputFile);
 
   // Initialize M_.Sigma_e, M_.Correlation_matrix, M_.H, and M_.Correlation_matrix_ME
diff --git a/src/SubModel.cc b/src/SubModel.cc
index 731993e2b2af3a923b94f74c96ffcb2883bb82fa..679a12c3a6b34f9748652e71320bed9cb56a6abf 100644
--- a/src/SubModel.cc
+++ b/src/SubModel.cc
@@ -334,7 +334,7 @@ VarModelTable::writeOutput(ostream &output) const
   for (const auto &name : names)
     {
       output << "M_.var." << name << ".model_name = '" << name << "';" << endl;
-      if (!symbol_list_and_order.empty())
+      if (!symbol_list_and_order.at(name).first.empty())
         {
           symbol_list_and_order.at(name).first.writeOutput("M_.var." + name + ".var_list_", output);
           output  << "M_.var." << name << ".order = "