It seems that everyone who learns OCaml comes away with the impression that functional programming is the New Cool Thing, and imperative programming is Bad and Must Be Avoided.
I'm going to say it now: programming fashions are stupid and counterproductive. The only things that matter are that your program is short, easy to write, easy to maintain and works correctly. How you achieve this has nothing to do with programming fads.
Reading all lines from a file is an imperative problem, and the shortest solution (easy to write, easy to maintain and correct1) uses a while loop, in OCaml or any other language:
let lines = ref  inActually, no, I'm lying. The best solution is this:
let chan = open_in filename in
while true; do
lines := input_line chan :: !lines
with End_of_file ->
Std.input_list chanwhich is supplied by extlib. Don't bother to duplicate functions which are already provided in commonly available libraries.
1This is only strictly speaking correct if you handle clean-up if
input_linethrows some read error (exception). In the common case where you just exit the program, leaving the channel open is perfectly acceptable.