TX/RX problem

So I was trying to command my gsm shield to send sms.

String number;
String msg;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);

}

void loop() {

delay(500);
Serial.print("Enter a mobile number: ");
while(Serial.available()==0) {

}
number = Serial.readString();
delay(300);
Serial.print("OK");

delay(1000);
Serial.print("Now, enter SMS content: ");
while(Serial.available()==0) {

}
msg = Serial.readString();

delay(1500);
Serial.print("\r");
delay(1000);
Serial.print("AT+CMGF=1\r");
delay(1000);
Serial.print("AT+CMGS="+63" + number + ""\r"); //Number to which you want to send the sms
delay(1000);
Serial.print(msg + "\r"); //The text of the message to be sent
delay(1000);
Serial.write(0x1A);
delay(1000);

}

But everytime I enter a string when the program prompts me to, the program freeze. But when I did it while my tx and rx is disconnected it works fine but of course it doesnt send the sms. Could you guys help me Im just a newbie.. Thanks

Hardware:
Arduino Uno R3
Sim900 Gsm Shield

But when I did it while my tx and rx is disconnected it works fine but of course it doesnt send the sms.

Are you trying to use pins 0 and 1 to communicate with the PC? Or, are you using those pins to communicate with the GSM modem? Both is the wrong answer. So is yes.