only write number of bytes read