What is the best way to receive unsolicited response from GSM SIM900 in PIC18
Thanks to @Bence Kaulics  &amp; @m.Alin. I have solved the issue by double checking the \r \n. Following is the code I used:

volatile int flag = -1;   
volatile int sFlag = 0; 
volatile int uFlag = 0;

void rx_handler(void)
{
    rxData[index] = ReadUSART();

    if(rxData[index]=='\n' &amp;&amp; rxData[index-1]== '\r' )
    {
      flag = flag + 1;

      if(flag == 1)    
      {
         sFlag = 1;
      }
    }

}

index++;

PIR1bits.RCIF==0;

}


I have used a flag = -1. So when I first got \r \n value of flag is 0. And again when I got \r \n that means we have detected a line end and this is what we are expecting so set sFlag = 1. When sFlag = 1 that means we have received the data and now we can process it.