Program came out of for loop early

I was running a program that controles two relays fromm 5v to 120v and before the for loop reached it's value to end it stopped. I have the button pulled to ground. Electrical interfere from the 120v maybe? Should the microcontroller be grounded to the 120v?

Void loop
digitalWrite (led,high)
If (digitalRead(button)==high){
a=1;
digitalWrite(led,low);
}

While (a==1){

For(x=0,x<20000,x++){
....
........}
a=0;
}

Do you have a programming question?

Beanbeater123:
For(x=0,x<20000,x++)

Note the difference:

for( int a = 10; a < 20; a++ )

Your code cannot even compile, let alone run

Please don't waste our time - post you actual code.