Obvious question: do you ever close the connection at the other end?
NetworkStream.Read will return 0 if and only if the connection has been terminated (otherwise it will block until there is at least one byte). So check for that in your loop condition. Read will also never read more than the maximum size you pass it as a parameter, so the check you're doing right now is pointless. Try
while(0 < stream.Read( ... )) { ... }