Check if the stream is valid.