Help with combining 2 sketches together.

If the the file cant be open then skip everything else.

In which case that code should be:-

 if (Serial.available() > 0)
  {

    incomingByte = Serial.read();
    if (incomingByte == 'R')
    {
      Serial.begin(115200);
      if (!myFile.open("codes.txt", O_READ)) { // you missed this opening brace
      Serial.println("code.txt:");
      int data;
      while ((data = myFile.read()) > 0) Serial.write(data);
      // close the file:
      myFile.close();
      
      }
  } // this is the matching closing brace

    }