System.IO.readFile/writeFile uses the default encoding of the system which may be problematic (see real world issue).
readFile is lazy by default:
readFile "text" >>= writeFile "text" . map toUpperwill fail (resource is busy) unless readFile is strict.Data.ByteString.Lazy.readFilecloses the file after all bytes are read (which may never happen).System.IO.withFilecloses it for you but it is dangerous e.g.withFile "input.txt" ReadMode hGetContents >>= write "output.txt"throwshGetContents: illegal operation (delayed read on closed handle)the file is closed before the data is actually read (the data is lazily read).