Hello all, I was playing with some Haskell code that read in text files and processed them and often found myself writing empty result-files. I've pared the problem down to the following small example.
-- example program
import IO
main = do
rhdl <- openFile "test.in" ReadMode
content <- hGetContents rhdl
putStrLn content -- if I cmt out this line, content will be empty
hClose rhdl
putStrLn "Content: "
putStrLn content -- if the first 'putStrLn' call was commented, this will print a blank line
-- end example
For some reason, if I comment out the 'putStrLn content' between hGetContents and hClose, the data from the hGetContents call is not stored. Can somebody verify this behavior and (if so) explain why it's happening?
Thanks,
-- kov