diff --git a/index.js b/index.js
index 2b92b53..42681cb 100644
--- a/index.js
+++ b/index.js
@@ -146,7 +146,10 @@ module.exports = function(options) {
treeAdapter.appendChild(docFragment, node);
var tpl = parse5.serialize(docFragment);
- tpl = tpl.replace('', '').replace('', '');
+
+ var lastTemplateCloseTagEntryIndex = tpl.lastIndexOf('');
+ tpl = tpl.substring(0, lastTemplateCloseTagEntryIndex)
+ .replace('', '');
}
tpl.split("\n").forEach(function(line){
@@ -231,4 +234,4 @@ module.exports = function(options) {
callback(null, file);
});
-}
\ No newline at end of file
+}