Check open state on IO retry

Someone might have closed the file descriptor before we do the retry.

Fixes #2757