Sounds like the problem may be in the "other device" that is communicating with the Mega, since changing the USB-to-serial interface solves the problem. The Mega itself cannot tell what is connected to the Rx and Tx pins (as long as you do not overload them), so the code is likely working fine with the on-board USB-to-serial interface and your "other device" is not handling the USB connection properly.