It is, BTW, always preferable to use withFile over openFile, if you can.
This makes your code cleaner and also exception-safe.
Hi Ertugrul,
I don't think I quite understand. How is withFile
exception-safe? Under the covers it's using openFile. I was under
the impression withFile was just a nice way to remove boilerplate
file operation code. Here's what I found on hoogle: "withFilename mode act opens a
file usingopenFileand passes the resulting
handle to the computation act. The handle will be closed on exit
fromwithFile, whether by
normal termination or by raising an exception."