I think we might want to do this decrementing in the loop, toCopy bytes at a time. Otherwise if `OutputStream.write()` throws an IOException then size and the segments get out of sync.