
John Goerzen writes:
That failed, though, because getContents closes the file after it's been completely read (ugh -- why?).
getContents reads from standard input: you can't seek on
that stream. Just think of "cat
But I couldn't figure out a way to make this either properly tail-recursive while handling the exception, or to avoid polling for EOF each time through the function.
You might want to write a function that copies the file _once_ and then just call that function several times. Like in the examples above. I don't think you need explicit recursion at all. Hope this is helpful. Peter