SshChannel class is very low API. For common cases you don't need to use it.
If you want to use SSH protocol for file transfers, use rather Sftp class or Scp class.
If you want to script a shell, use rather Scripting class.
If for some reason you really want to use low level
SshChannel class then call
Receive in a loop as you have written.