Troubleshooting Program that reads Serial Input

OK. I am officially baffled.

123 I received: 123.000 <123> I received: 0.000 Error! 123\n I received: 123.000 <123>\n I received: 0.000 Error!

Do me the favor of starting from scratch. Close the IDE. Open a new instance of the IDE, select and copy the code from reply #4 and paste it into a blank IDE window. Upload the code and try it again in a new serial monitor window.

If you unplug the Arduino while the serial monitor is open, the serial monitor loses the connection and serial monitor must be restarted (closed and opened again) to restore communication.