This looks like a potential stack overflow to me, `st1` should be strict. Also, this solution seems to have non-deterministic behaviour, inherent to lazy IO. For instance, what if for some reason the consumer didn't read until the end, when will the cursor be closed?