Faulty code in ethernet/wifi examples?

I have a wifi project running successfully for several days, and am now finishing an ethernet project to start testing, and I ran into the same problem on both borrowing code from the examples.

The example shows

// if there are incoming bytes available 
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

The program does not connect more than once using this code.

I had to remove the if (!client.connected()) statement and just use the client.stop(), then it worked fine.

Also, as per @SurferTim suggestion, I am using this statement instead of the first if

while(client.connected()) {
    while(client.available()) {
      char ch = client.read();
      Serial.write(ch);
    }

Is there anything wrong with NOT putting the client.stop() in the if statement? If not, then why do the examples include it when it is apparently not only unnecessary, but problematic?

No problem with the client.stop outside that if statement. There is a possibility my while loop will become an endless loop if there is no timeout feature.

I have it on a watchdog, so if that happens it will just reset. At any rate, I guess it couldn't hurt to put a 6 second timeout since the watchdog is every 8 seconds.

Shouldn't the examples then do away with the if statement since it's unnecessary?

I don't use the watchdog because my client code in the playground has its own timeout feature.

I don't know about the examples. I didn't write those.

pekasus:
Is there anything wrong with NOT putting the client.stop() in the if statement? If not, then why do the examples include it when it is apparently not only unnecessary, but problematic?

Just curios - why not simply put the second if statement as an else to the first if statement, since the sketch has to choose one or the other and u retain the functionality of the stop.

There is no "if" in the code. It should be two while loops, one inside the other. When it exits the outer while, then client.stop.

To clarify, I was referring to the originally posted code.
It has 2 if statements.