Arduino keeps restarting sketch

I am powering the Arduino through the USB port.

I put those Serial.flush(); since the Serial.print(); wouldn't print all the messages (it would print some, but not all). The Serial.print() is only for debugging purposes, so I can see the output on the IDE window (btw, Arduino 1.0.1). To connect the Arduino to the XBee I am using the ArduinoXBeeShield.

I am using Arduino Uno rev 3, XBee Pro S2.

Here is a picture:

Thank you!