let lines_of_chars cstr =
let f _ =
match peek cstr with
| None -> None
| Some _ ->
let ans = Buffer.create 100 in
let rec loop () =
try
let c = next cstr in
if c <> '\n' then (Buffer.add_char ans c; loop())
with Failure -> ()
in
loop();
Some (Buffer.contents ans)
in
from f