Add multiple I/O attempts on failure instead of immediate abort.

This implementation could be extended a little. There should be some safety implemented around the reversibility check writing, the number of attempts and timeout between them should probably be configurable and the whole block could probably be moved into a separate subroutine.

However, I believe this code already presents a significant improvement over the previous implementation when the I/O is unreliable.