Try changing that "if" to a "while" to read all available characters before checking for a closed connection. That's because your connection may already be closed but you still have bytes in your input buffer (on the Ethernet Shield).
Try changing that "if" to a "while" to read all available characters before checking for a closed connection. That's because your connection may already be closed but you still have bytes in your input buffer (on the Ethernet Shield).