I am writing a Python script to read a SMS from the SIM memory, buffer it and send the same SMS to another number. I am executing this script on Telit GM862-GPS gsm modem.
The script I have written is :

import MDM

MDM.send('AT+CMGF=1\r', 10) # Changing to Text mode
MDM.send('AT+CMGR=1\r',0) # Reading SMS at index 1
a = MDM.receive(10) # Receiving as string

MDM.send('AT+CMGS="Phone no.", 129', 0) #selecting a particular no.
MDM.send(a, 0) # sending retrieved SMS
MDM.sendbyte(0x1A, 0) # sending Ctrl Z

But I am facing this problem:
After executing "AT+CMGR=1 \r" command, the script doesn't execute commands after that. I have checked this by putting a simple AT command to change some value after "Read SMS" command & that value doesnt get changed. I dont know for what weird reason its doing this.

It would be really helpful if someone can help me out with this.