This is what I have so far. Isn\'t this all that you need? I keep getting the error \"Error: Unbound module Std\"
let r file =
let chan = open_in file in
Here is a simple recursive solution that does not accumulate the lines or use external libraries, but lets you read a line, process it using a function, read the next recursively until done, then exit cleanly. The exit function closes the open filehandle and signals success to the calling program.
let read_lines file process =
let in_ch = open_in file in
let rec read_line () =
let line = try input_line in_ch with End_of_file -> exit 0
in (* process line in this block, then read the next line *)
process line;
read_line ();
in read_line ();;
read_lines some_file print_endline;;