Retry file write when a ClosedByInterruptException is thrown