Check for EOF when reading subtitle lines.
[srt2vtt.git] / srt2vtt
diff --git a/srt2vtt b/srt2vtt
index 27e0927e23b3b28c7418cbc085e2d4e2e434fad8..a4cb576042aabd05915205eb495a5116608c1dd0 100755 (executable)
--- a/srt2vtt
+++ b/srt2vtt
@@ -1,4 +1,4 @@
-#!/usr/bin/guile --no-auto-compile
+#!/usr/bin/guile
 -*- scheme -*-
 !#
 
@@ -66,7 +66,10 @@ two values: the start time and the end time.  Valid input looks like
                ((start end) (parse-time-span (read-line port)))
                ((lines) (let loop ((lines '()))
                           (let ((line (read-line port)))
-                            (if (string-null? line)
+                            (if (or (eof-object? line)
+                                    (and (string-null? line)
+                                         ;; A subtitle may be a blank line!
+                                         (not (null? lines))))
                                 lines
                                 (loop (cons line lines)))))))
     (make-subtitle id start end lines)))