Index: generic/tclIO.c
==================================================================
--- generic/tclIO.c
+++ generic/tclIO.c
@@ -2613,17 +2613,18 @@
      * channel becomes writable again. This ensures that all of the pending
      * data has been flushed at the system level.
      */
 
     if (statePtr->flags & BG_FLUSH_SCHEDULED) {
-	if (wroteSome) {
-	    return errorCode;
-	} else if (statePtr->outQueueHead == NULL) {
+	if (statePtr->outQueueHead == NULL) {
 	    ResetFlag(statePtr, BG_FLUSH_SCHEDULED);
 	    (chanPtr->typePtr->watchProc)(chanPtr->instanceData,
 		    statePtr->interestMask);
 	}
+	if (wroteSome) {
+	    return errorCode;
+	}
     }
 
     /*
      * If the channel is flagged as closed, delete it when the refCount drops
      * to zero, the output queue is empty and there is no output in the

