You are waiting for the pin to be low. Do you have a pullup on your pin so when it's released the pin has 5v on it?