fix wrote bytes count