diff --git a/aidge_core/export_utils/code_generation.py b/aidge_core/export_utils/code_generation.py
index d48970b0fcf247bef0c3df4052837ab78e360238..995df18b52d5701af5259d571e6a0a91a83ba665 100644
--- a/aidge_core/export_utils/code_generation.py
+++ b/aidge_core/export_utils/code_generation.py
@@ -40,7 +40,7 @@ def generate_str(template_path: Union[Path, str], **kwargs) -> str:
     if isinstance(template_path, str):
         template_path = Path(template_path)
     return Environment(loader=FileSystemLoader(
-        template_path.parent), undefined=StrictUndefined).get_template(template_path.name).render(kwargs)
+        template_path.parent), undefined=StrictUndefined, keep_trailing_newline=True).get_template(template_path.name).render(kwargs)
 
 def copy_file(filename, dst_folder):