interrupt loop while receiving data

Have a look at the examples in Serial Input Basics. The variable newData is set to true when data has arrived. You can test for that before allowing something else to happen. The showData() function uses it like that.

...R