Count of bytes was off by one (one too many)

I'm also not sure if there is a specific reason why this must be read
in chunks. Performace for network streams?

It would be a lot simpler to do this instead

   data = r.ReadToEnd().ToCharArray();
   n = data.Length;