Instead of storing IOResult, simply read InOutRes instead. Same thing but it doesn't get wiped. Note that this will *NOT* work in Delphi, though. However, you don't really need $I- in Delphi, exceptions are so much better.
As for error logs--you need to at least flush and commit (note...