Program stops after button press

Loop is executed very frequently. Instead of incrementing the counter when the switch is HIGH, you need to increment if it is HIGH and was LOW. In other words, a transition.