withFile package:Cabal

Gets the contents of a file, but guarantee that it gets closed. The file is read lazily; if it is not fully consumed by the action then an exception is thrown.