Close resource stream after reading a range of bytes