diff --git a/DynareMain.cc b/DynareMain.cc
index 016488682a936d55d2b132c90acde5d9a07c9467..7fed1e7858964a73f3421dc7d5664b2fa1288f6b 100644
--- a/DynareMain.cc
+++ b/DynareMain.cc
@@ -215,7 +215,7 @@ main(int argc, char **argv)
         }
       else if (strlen(argv[arg]) >= 8 && !strncmp(argv[arg], "language", 8))
         {
-	  if (strlen(argv[arg]) <= 9 || argv[arg][6] != '=')
+	  if (strlen(argv[arg]) <= 9 || argv[arg][8] != '=')
 	    {
 	      cerr << "Incorrect syntax for language option" << endl;
 	      usage();
@@ -234,7 +234,7 @@ main(int argc, char **argv)
 	    language = python;
 	  else
 	    {
-	      cerr << "Incorrect syntax for ouput option" << endl;
+	      cerr << "Incorrect syntax for language option" << endl;
 	      usage();
             }
         }
diff --git a/DynareMain2.cc b/DynareMain2.cc
index 60a06064ae113ddc2839bd6932124f1c1299b972..8f82a059f81940be169ac5bc731312dc0f6f6590 100644
--- a/DynareMain2.cc
+++ b/DynareMain2.cc
@@ -27,7 +27,7 @@
 void
 main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive,
       bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
-      bool parallel_test, bool nostrict, FileOutputType output_mode, LanguageOutputType lang
+      bool parallel_test, bool nostrict, FileOutputType output_mode, LanguageOutputType language
 #if defined(_WIN32) || defined(__CYGWIN32__)
       , bool cygwin, bool msvc
 #endif
@@ -58,7 +58,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tm
 
   // Write outputs
   if (output_mode != none)
-    mod_file->writeExternalFiles(basename, output_mode, cuda);
+    mod_file->writeExternalFiles(basename, output_mode, language);
   else
     mod_file->writeOutputFiles(basename, clear_all, no_log, no_warn, console, nograph, nointeractive, config_file
 #if defined(_WIN32) || defined(__CYGWIN32__)