diff --git a/src/HeaderComment/FormattedHeaderProvider.php b/src/HeaderComment/FormattedHeaderProvider.php
index f6a65a2d67801a6925f3f4550e4ea9541c27e104..9afe58ea4cc1dffb4f33482007e69aec09d9a6d8 100644
--- a/src/HeaderComment/FormattedHeaderProvider.php
+++ b/src/HeaderComment/FormattedHeaderProvider.php
@@ -5,7 +5,6 @@
  *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
- *
  */
 
 namespace Irstea\CS\HeaderComment;
@@ -39,7 +38,7 @@ final class FormattedHeaderProvider implements HeaderProviderInterface
      */
     public function getHeader(): ?string
     {
-        $template = $this->templateProvider->getTemplate();
+        $template = trim($this->templateProvider->getTemplate());
 
         return $template ? $this->templateFormatter->format($template) : null;
     }
diff --git a/src/HeaderComment/UserDefinedTemplateProvider.php b/src/HeaderComment/UserDefinedTemplateProvider.php
index df92ba419c28c0ac673eb5be1698f5969d09dbba..9d390f5772d14666c81772e41e4d3d4d55005752 100644
--- a/src/HeaderComment/UserDefinedTemplateProvider.php
+++ b/src/HeaderComment/UserDefinedTemplateProvider.php
@@ -5,7 +5,6 @@
  *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
- *
  */
 
 namespace Irstea\CS\HeaderComment;
@@ -37,6 +36,6 @@ final class UserDefinedTemplateProvider implements TemplateProviderInterface
     {
         $path = $this->fileLocator->locate('.docheader');
 
-        return $path ? trim(file_get_contents($path)) : null;
+        return $path ? file_get_contents($path) : null;
     }
 }