Wifi shield and output pins

First, you should post what the symptoms are. Does the Arduino keep running or lock up? What is the serial monitor show when it fails?

You could be running out of SRAM. That causes weird fails.

You may not be waiting long enough for a response from the server. This doesn't wait for a response. You are supposed to wait for the server to close the connection before closing your end. This doesn't. And if the client is still connected, this won't close the connection.

  while (client.available()) {
    char c = client.read();
    Serial.write(c);
    response=response+c;
  }

  // if the server's disconnected, stop the client:
  // if the server is still connected, leave the connection open and lose the socket
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting from server.");
    client.stop();
  }