How to stop for loop when receive serial strings from serial port.