As a general sort of warning, do not use hGetContents (or lazy i/o, in general) in combination with withFile.
withFile closes the handle when the program lexically exits its scope. However, when using hGetContents, the file contents will not be read until after you do this, and will therefore fail to be read at all; I'm not sure whether this will produce a truncated string or an exception. Instead, use openFile directly. Handles have (ISTR) finalizers on them, and so should be automatically closed if you lose hold of one.. eventually. getContents of course closes it once it hits EOF, but that isn't exactly reliable. If that isn't satisfactory, use strict I/O. It's less convenient, but it's also easier to reason about. -- Svein Ove Aas _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe