(SOLVED)Can any one help?

Does anyone know a better way to collect data with error handling for what am trying to do?

//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 <= '~')
    {
      str[i++] = temp;
    }
    if(i == 16)
    {
      return 0;
    }
  }
  str[i] = '\0';
  return 1; //No data to read or buffer full.
}

Am wanting it to terminate the read when the 16 byte buffer gets full if no '>' is found and then flush out out anydata remaining before it starts again.