Techhack:
If I wiggle the usb connector and rerun the program after a few tries the load is good and the program runs perfectly.I have replaced the usb cable 6 times and it does not fix the problem so it must be the computer port.
That's possible but it also might be the USB socket on the Uno. Even if you only wiggle the plug at the computer's USB port you're probably unintentionally wiggling the other end of the cable where it's plugged into the Uno.
Techhack:
Is there a way to add some code to the Clean_Up that will check the connection between the computer through the usb cable to the board?
This will do it:
// Echos input from the serial monitor
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
Serial.write(Serial.read());
}
}
If you send some input to the Arduino and receive the same back you know the USB data lines have a connection, rather than only the power lines.