diff --git a/PlumedToHTML/PlumedToHTML.py b/PlumedToHTML/PlumedToHTML.py
index 78d0d0c..367b42d 100644
--- a/PlumedToHTML/PlumedToHTML.py
+++ b/PlumedToHTML/PlumedToHTML.py
@@ -260,7 +260,8 @@ def resolve_includes( srcdir, inpt, foundfiles ) :
final_inpt += "# " + clines+ "# ensures PLUMED loads the contents of the file called " + filename + "\n"
final_inpt += "# The contents of this file are shown below (click the red comment to hide them).\n"
foundfiles, parsed_inpt = resolve_includes( srcdir, include_contents, foundfiles )
- final_inpt += parsed_inpt + "#ENDEXPANSION " + filename + "\n"
+ if parsed_inpt.endswith("\n") : final_inpt += parsed_inpt + "#ENDEXPANSION " + filename + "\n"
+ else : final_inpt += parsed_inpt + "\n#ENDEXPANSION " + filename + "\n"
else : final_inpt += clines
return foundfiles, final_inpt
diff --git a/setup.py b/setup.py
index 6422e54..2e9a5e8 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@
setuptools.setup(
name='PlumedToHTML',
- version='0.53',
+ version='0.54',
author="Gareth Tribello",
author_email="gareth.tribello@gmail.com",
description="A package for creating pretified HTML for PLUMED files",