So, I believe that this is related to my problem. Is the Yun actually behaving like a Leonardo?
Yes, that is exactly your problem. The Yun is a Leonardo with a Linux WiFi/Ethernet router attached to the Serial1 pins (DO and D1). The "Arduino" side of it behaves exactly like a Leonardo.
I've tried commenting out the "while (!Serial)" statement, but this doesn't seem to have helped. I have several "Serial.println("....");" statements in my code that I use for debugging. I'd really prefer to not have to add and remove comments just to enable and disable the debugging output.
Yep, you've hit the conundrum. Keep the "while (!Serial)" in your sketch, and it won't run without the serial port being opened. Take it out, and you lose any initial debug messages that occur before you can make the connection.
This is further complicated by the fact that the Yun/Leonardo doesn't use a serial to USB converter chip, it uses the USB interface that is built into the processor. This has advantages in that it can act like other devices, such as a keyboard or mouse, but it has the disadvantage that the USB connection goes away each time you reset the processor, and is not available until the host computer re-enumerates the USB port and establishes a new serial connection. So you can never see the initial debug output without the "while (!Serial)" statement.
It's not a problem to be sending things out the serial port before you have a connection, so you don't have to disable all of your debug output. But you do have to either disable the while statement and miss your initial debug output, or work around it.
If you have free I/O pins, you could use one of them as a debug indicator: set the pin as input with pullup. After that, check the pin, and do the "while (!Serial)" only if the pin is low. With the pin disconnected, the pullup will make the input high, and the sketch won't wait. But if you want the debug output, put in a jumper wire to pull that pin to ground, and then the sketch will wait until you make a connection.
A trick I've done is take out the wait, but put a "if (Serial)" test in loop(). If this is the first time it was seen as true (I use a boolean flag to determine that) I print out a sign-on banner and initial sketch information (which was saved in local variables if necessary.) That way, the sketch starts and runs, but when I connect to the serial port, I still get that initial saved output. The downside is that this only works once: there is no way to know that the USB serial port has disconnected, so the initial information only prints out once, not every time a connection is established.