Index: generic/tclIO.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIO.c,v
retrieving revision 1.137.2.14
diff -w -u -r1.137.2.14 tclIO.c
--- generic/tclIO.c	11 Nov 2009 00:04:27 -0000	1.137.2.14
+++ generic/tclIO.c	12 Nov 2009 00:07:17 -0000
@@ -8588,7 +8588,7 @@
     Tcl_Obj *cmdPtr, *errObj = NULL, *bufObj = NULL, *msg = NULL;
     Tcl_Channel inChan, outChan;
     ChannelState *inStatePtr, *outStatePtr;
-    int result = TCL_OK, size, total, sizeb;
+    int result = TCL_OK, size, total, sizeb, haveRead;
     char *buffer;
     int inBinary, outBinary, sameEncoding;
 				/* Encoding control */
@@ -8709,6 +8709,8 @@
 	    }
 	}
 
+	haveRead = size;
+
 	/*
 	 * Now write the buffer out.
 	 */
@@ -8762,9 +8764,9 @@
 	 */
 
 	if (csPtr->toRead != -1) {
-	    csPtr->toRead -= size;
+	    csPtr->toRead -= haveRead;
 	}
-	csPtr->total += size;
+	csPtr->total += haveRead;
 
 	/*
 	 * Break loop if EOF && (size>0)
