Agree on what you say, PaulS, but the OP structured the code expecting it to block on getSerial() until it gets a number.
Short of changing the entire structure of the program, this is the easiest way to get OPs code working so that he can progress. What is there now will become a limitation later IF he needs to do other things