Arduino Mega 2560 Serial Input Cycle Problem

Please run the code you post. That latest one won't compile on an Uno and I'm not going to bother trying to figure out what you really did.