diff --git a/src/macro/Driver.cc b/src/macro/Driver.cc
index c0419e020b340c2103bce13299c1aabe7c439b6d..9fb99b2644558ce56db59316c28c21e984bf7279 100644
--- a/src/macro/Driver.cc
+++ b/src/macro/Driver.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019-2020 Dynare Team
+ * Copyright © 2019-2022 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -40,10 +40,6 @@ Driver::parse(const string &file_arg, const string &basename_arg, const istream
       m.parse("command_line_defines", "command_line_defines", is, debug, {}, env, paths, output);
     }
 
-  // Handle empty files
-  if (modfile.rdbuf()->in_avail() == 0)
-    return;
-
   stringstream file_with_endl;
   file_with_endl << modfile.rdbuf() << endl;
 
diff --git a/src/macro/Parser.yy b/src/macro/Parser.yy
index bf029618f98e648062b391dc9190f7b157c6f2af..be7cc71ec1e1d8d593a78318af77ee9da8fbc4c7 100644
--- a/src/macro/Parser.yy
+++ b/src/macro/Parser.yy
@@ -1,6 +1,6 @@
 // -*- C++ -*-
 /*
- * Copyright © 2019-2021 Dynare Team
+ * Copyright © 2019-2022 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -105,7 +105,11 @@ using namespace macro;
 
 %%
 
-%start statements;
+%start statements_or_empty_file;
+
+statements_or_empty_file : %empty
+                         | statements
+                         ;
 
 statements : statement
              {