From: Julien Cristau <julien.cristau@ens-lyon.org>
Date: Sun, 1 Sep 2019 21:33:40 +0200
Subject: Patch to detect the end of the header

---
 main.ml  | 4 ++--
 model.ml | 8 +++++++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/main.ml b/main.ml
index 603035e..972a349 100644
--- a/main.ml
+++ b/main.ml
@@ -89,7 +89,7 @@ let read_headerfile filename =
       let line = input_line ic in
       line :: loop ()
     with
-      End_of_file -> []
+      End_of_file -> close_in ic; []
   in
   loop ()
 
@@ -221,4 +221,4 @@ let () =
     main ()
   with
     Sys_error msg ->
-      eprintf "%s: %s" Sys.argv.(0) msg
+      eprintf "%s: %s\n" Sys.argv.(0) msg
diff --git a/model.ml b/model.ml
index 32d46bf..b9163e9 100644
--- a/model.ml
+++ b/model.ml
@@ -138,6 +138,8 @@ let make_lines ~open_comment ~close_comment ~line_char ~begin_line
   let regexp_end = 
     Str.regexp_string (sprintf "%s%s" (String.make 10 line_char) close_comment)
   in
+  let end_length = 10 + String.length close_comment
+  in
 
   let regexp_blank = Str.regexp "^[ ]*$" in
 
@@ -146,7 +148,11 @@ let make_lines ~open_comment ~close_comment ~line_char ~begin_line
       let line = input_line ic in
       if Str.string_match regexp_begin line 0
       then begin
-	while not (Str.string_match regexp_end (input_line ic) 0) do () done;
+	while
+          let s = input_line ic in
+            not (Str.string_match regexp_end s
+                   (max 0 (String.length s - end_length)))
+        do () done;
 	""
       end
       else if Str.string_match regexp_blank line 0 
