diff --git a/src/ModFile.cc b/src/ModFile.cc
index 1eed44bb5a372eb10bbef0e9b7a56595877ce75e..98db35d102430e461ddf16b6991bf379d2e7294c 100644
--- a/src/ModFile.cc
+++ b/src/ModFile.cc
@@ -845,10 +845,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
                           const filesystem::path &matlabroot,
                           const filesystem::path &dynareroot, bool onlymodel) const
 {
-  bool hasModelChanged = !dynamic_model.isChecksumMatching(basename, block);
-  if (!check_model_changes)
-    hasModelChanged = true;
-
+  bool hasModelChanged = !dynamic_model.isChecksumMatching(basename, block) || !check_model_changes;
   if (hasModelChanged)
     {
       // Erase possible remnants of previous runs