problem web server and read/write sd card

hello, anyone knows why when I try to write into the setup in the SD card and I want to read into the loop from the data of SD card on the internet with the web server configuration and I can not. If you test only read or only write the code works but when do you try both at the same time not works

any idea, thanks

#include <SPI.h>
#include <SD.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>
#include <util.h>
/********************/
byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0x5C, 0x18};
/********************/
EthernetServer server(80);
/********************/
String readString;
/********************/
File myfile;
/********************/

void setup()
{
  pinMode(9, OUTPUT); 
  digitalWrite(9,LOW);
/**********************************/  
  Serial.begin(9600);
  Serial.println("COMUNICACION SERIAL");
  delay(2000);
/**********************************/
  SD.begin();
  pinMode(4,OUTPUT);
  if (SD.begin(4))
  {
    Serial.println("MICRSD");
  }
  else
  {
    if (!SD.begin(4))
    {
      Serial.println("MICRSD PROBLEMA");
    }
  }
  delay(2000);
/**********************************/
  if (Ethernet.begin(mac) == 0)
  {
    Serial.println("PROBLEMA RED");
  }
  else
  {
    if (!Ethernet.begin(mac) == 0)
    {
      Serial.print("IP : ");
      for (byte thisByte = 0; thisByte < 4; thisByte++) 
      {
        Serial.print(Ethernet.localIP()[thisByte], DEC);
        Serial.print("."); 
      }   
    }
  }
  delay(2000);
/**********************************/
  Serial.println();
  server.begin();
  Serial.println("SERVER");
  delay(2000);
/**********************************
  myfile = SD.open("evento.txt",FILE_WRITE);
  if (myfile) 
  {
    Serial.println("WRITE DOC");
    myfile.println("TEST SAVE DATA");
    myfile.close();
    Serial.println("DONE");
  } 
  else 
  {
    Serial.println("ERROR DOC");
  }
/**********************************/
}

void loop()
{
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (readString.length() < 100) {
          readString += c;
        if (c == '\n') {
          Serial.println(readString);
          if(readString.indexOf('?') >=0) { 
            client.println("HTTP/1.1 204 Zoomkat");
            client.println();
            client.println();  
          }
          else {   
            client.println("HTTP/1.1 200 OK"); 
            client.println("Content-Type: text/html");
            client.println();

            client.println("<HTML>");
            client.println("<HEAD>");
            client.println("<TITLE>Arduino GET test page</TITLE>");
            client.println("</HEAD>");
            client.println("<BODY>");

            client.println("<H1>WEB SERVER READ/WRITE SD CARD</H1>");
            
            client.println("
");

            client.println("<a href='/?on' target='inlineframe'>ON</a>"); 
            client.println("<a href='/?off' target='inlineframe'>OFF</a>"); 

            client.println("<IFRAME name=inlineframe style='display:none'>");          
            client.println("</IFRAME>");
            
            client.println("
");
            client.println("
");
            client.println("
");           

            client.println("</BODY>");
            client.println("</HTML>");
          }
          
          /***********************************/
          myfile = SD.open("evento.txt");
          if (myfile) 
          {
            Serial.println("READ DOC");
            while (myfile.available()) 
            {
    	       client.write(myfile.read());
            }
            myfile.close();
          } 
          else 
          {
            Serial.println("ERROR DOC");
          }
          /***********************************/
          
          delay(1);
          client.stop();
          
          if(readString.indexOf("on") >0)
          {
            digitalWrite(9, HIGH);    
            Serial.println("Led On");
          }
          
          if(readString.indexOf("off") >0)
          {
            digitalWrite(9, LOW);    
            Serial.println("Led Off");
          }
          readString="";          
        }
       }
      }
    }
  }
}

Is this Arduino an Uno?

When you try both at the same time, what does the serial monitor output look like? Does the sketch lock up or keep running?

Why are you calling SD.begin() multiple times?

  SD.begin();
  pinMode(4,OUTPUT);
  if (SD.begin(4))
  {
    Serial.println("MICRSD");
  }
  else
  {
    if (!SD.begin(4))
    {
      Serial.println("MICRSD PROBLEMA");
    }
  }

Once should be plenty. All you should need is this:

    if (!SD.begin(4)) Serial.println("MICRSD PROBLEMA");
    else Serial.println(F("SD ok"));