diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc
index 47371866cf281efe162002d8e368c24464bad77e..1fbe8a386ee98d8ad8e57d714e79c65713caa013 100644
--- a/preprocessor/ModFile.cc
+++ b/preprocessor/ModFile.cc
@@ -640,8 +640,10 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, b
if (!no_warn)
{
- mOutputFile << "disp('Note: " << warnings.countWarnings() << " warning(s) encountered in the preprocessor')" << endl
- << "if ~isempty(lastwarn)" << endl
+ if (warnings.countWarnings() > 0)
+ mOutputFile << "disp('Note: " << warnings.countWarnings() << " warning(s) encountered in the preprocessor')" << endl;
+
+ mOutputFile << "if ~isempty(lastwarn)" << endl
<< " disp('Note: warning(s) encountered in MATLAB/Octave code')" << endl
<< "end" << endl;
}