[Haskell-beginners] File I/O: reading from, writing to, same file in one function