
(1) At least, the definition should say that the behaviour is undefined if a program ever writes to a file that it has read with `readFile' or `hGetContents' before.
This restriction would be too harsh. It is desirable to be able to write to a file that has been read before with `readFile' or `hGetContents'. With hGetContents you can do this safely: do handle <- openFile "configuration" ReadMode contents <- hGetContents ... hClose handle writeFile "configuration" newContents At the point where you write newContents, you should no longer be interested in contents. Either, because you are at the end of the program execution anyway (as in Manuel's example), or because you checked that you could parse the contents and hence processed the whole contents, e.g.: ... case parse contents of Nothing -> error "corrupted file format" Just info -> ... I would think that the later case is very common and then you do not even have to use `hClose'. However, I would prefer to do so and it is unfortunate that you cannot when you use `readFile'. Maybe these points should be mentioned in the report. Another point: I had difficulties parsing the following sentence of Section 11.2.2 on first reading: Any operation except for hClose that fails because a handle is closed, also fails if a handle is semi-closed. Alternatives: Any operation (except for hClose) that fails because a handle is closed, also fails if a handle is semi-closed. Any operation that fails because a handle is closed, also fails if a handle is semi-closed. The only exception is hClose. Olaf -- OLAF CHITIL, Dept. of Computer Science, University of York, York YO10 5DD, UK. URL: http://www.cs.york.ac.uk/~olaf/ Tel: +44 1904 434756; Fax: +44 1904 432767