Trouble sending USSD Commands to GSM module in Arduino GSM 1400

Hi Guys. I am working on a project where I have to send and receive response from USSD calls.
The code in the below link seems to be working fine.

"https://github.com/arduino-libraries/MKRGSM/blob/master/examples/Tools/SerialGSMPassthrough/SerialGSMPassthrough.ino"

unsigned long baud = 115200;

void setup() {
  // reset the ublox module
  pinMode(GSM_RESETN, OUTPUT);
  digitalWrite(GSM_RESETN, HIGH);
  delay(100);
  digitalWrite(GSM_RESETN, LOW);

  Serial.begin(baud);
  SerialGSM.begin(baud);
}

void loop() {
  if (Serial.available()) {
    SerialGSM.write(Serial.read());
  }

  if (SerialGSM.available()) {
    Serial.write(SerialGSM.read());
  }
}

The above is a simple code that will allow us to enter an AT code and display back its result.

But what I want is, instead of typing the AT command in the serial monitor, I want to include it in the program. I tried to modify the code as shown below but it isnt working.

unsigned long baud = 115200;

void setup() {
  // reset the ublox module
  pinMode(GSM_RESETN, OUTPUT);
  digitalWrite(GSM_RESETN, HIGH);
  delay(100);
  digitalWrite(GSM_RESETN, LOW);

  Serial.begin(baud);
  SerialGSM.begin(baud);
}

void loop() {
SerialGSM.write("AT+CUSD=1,\"*567#\"");


  if (SerialGSM.available()) {
    Serial.write(SerialGSM.read());
  }
}

Could you please help?