diff --git a/include/html2text.php b/include/html2text.php
index 944c62f19b2472bed206b8bfeed6b3e8219d241e..ba1e1389d9d4243b8c19a00be57c31b570c9b73e 100644
--- a/include/html2text.php
+++ b/include/html2text.php
@@ -361,7 +361,8 @@ class HtmlHeadlineElement extends HtmlBlockElement {
             default:
                 return $headline;
         }
-        $headline .= "\n" . str_repeat($line, strpos($headline, "\n", 1) - 1) . "\n";
+        $length = max(array_map('strlen', explode("\n", $headline)));
+        $headline .= "\n" . str_repeat($line, $length) . "\n";
         return $headline;
     }
 }