(SOLVED)Can any one help?

Yes thank you. The code below stops the skectch from crashing but when i type in the serial monitor 123456789123456789> (longer then 16 bytes) i then got the sketch to print out what it just received in the str and i get this 1234567891234567** (the * is garbage) but i think this tells me the code is still putting more then 16 bytes in the buffer.

//Reads data from the ELM IC.
//For example 41 0C 7B 7B>.
byte STN_Read(char *str)
{
  byte i = 0;
  char temp;
  
  while((temp = Serial.read()) != '>')
  {
    if(temp >= ' ' && temp <= '~')
    {
      Serial.println(i);
      Serial.println(temp);
      str[i++] = temp;
    }
    if(i == 16)
    {
      return 0;
    }
  }
  str[i] = '\0';
  return 1; //No data to read or buffer full.
}