9846584def
Modified the calculation of buf_len, so that scratch buffer allocates the memory according to requirement and not extra (except the last read chunk)