||Handle -> IO ()
hClose hdl makes handle hdl closed. Before the computation finishes, if hdl is writable its buffer is flushed as for hFlush. If the operation fails for any reason, any further operations on the handle will still fail as if hdl had been successfully
main = do hdl <- openFile "/tmp/foo.txt" WriteMode
hPutStr hdl "Hello, world!"
hdl <- openFile "/tmp/foo.txt" ReadMode
x <- hGetContents hdl
Output: Hello, world!