Be careful, input_line
is a footgun and has led to more than one bug out there – along with open_in
and open_out
defaulting to text mode and thus lying by default about your data.
input_line
will never report an empty final line and performs newline translations if your channel is in text mode. This means you can’t expect to recover the exact file contents you just read by doing String.concat "\n"
on the lines you input with input_line
.
Also of course it doesn’t help with making sure you correctly close your channels and don’t leak them in case of exception. The new functions finally make that a no brainer.