diff --git a/lib/LineCol.php b/lib/LineCol.php
index <HASH>..<HASH> 100644
--- a/lib/LineCol.php
+++ b/lib/LineCol.php
@@ -80,10 +80,11 @@ final class LineCol
         }
 
         throw new OutOfBoundsException(sprintf(
-            'Position %s:%s is larger than text length %s',
+            'Position %s:%s is larger than text length %s: %s',
             $this->line(),
             $this->col(),
-            strlen($text)
+            strlen($text),
+            $text
         ));
     }
 
diff --git a/lib/Util/LineAtOffset.php b/lib/Util/LineAtOffset.php
index <HASH>..<HASH> 100644
--- a/lib/Util/LineAtOffset.php
+++ b/lib/Util/LineAtOffset.php
@@ -26,7 +26,7 @@ final class LineAtOffset
         $lastLine = '';
         foreach ($lines as $line) {
             $end = $start + strlen($line);
-            if ($byteOffset >= $start && $byteOffset < $end) {
+            if ($byteOffset >= $start && $byteOffset <= $end) {
                 if (preg_match('{^(\r\n|\n|\r)$}', $line)) {
                     return $lastLine;
                 }
Fix bug with line-at-offset