let of_char_stream cstr =
let module Buffer = Biocaml_internal_pervasives.Buffer in
let f _ = match Stream.peek cstr with
| None -> None
| Some _ ->
let ans = Buffer.create 100 in
let rec loop () =
try
let c = Stream.next_exn cstr in
if c <> '\n' then (Buffer.add_char ans c; loop())
with Core.Std.Caml.Stream.Failure -> ()
in
loop();
Some (Buffer.contents ans |! Line.of_string_unsafe)
in
Stream.from f