problems with working with Handles

Markus.Schnell@infineon.com Markus.Schnell@infineon.com
Thu, 12 Jun 2003 18:37:05 +0200


> main = do --let inputfile  = "input.txt" 
>       let inputtext  = "testit"
>       let outputfile = "output.txt"
>       writeFile outputfile ""
>       handle2 <- openFileEx outputfile (BinaryMode WriteMode)
>       hPutStr handle2 (inputtext ++ " extra")
>      
>       handle3      <- openFileEx outputfile (BinaryMode ReadMode)
>       inputtext2   <- hGetContents handle3
>       handle4 <- openFileEx outputfile (BinaryMode WriteMode)
>       hPutStr handle4 (inputtext ++ " extra2")

Here's my guess: You open outputfile four times but never close it.

Markus