The problem is that readFile is lazy - it doesn't read the characters
at the time of readFile but rather as they are needed.  If you write
to a different file there's no problem.  In general, you have to be
careful not to use the file opened by readFile in other IO unless
you're sure you are finished with it.  A simple way to get around this
is to use a strict functlon like == to force the entire file contents:

 x <- readFile f
 if x == x then writeFile f (x ++ "more") else return ()

John

Reply via email to