Edit the following Python function to handle keyboard interrupts.
def main():
 try:
 counter = 0
 while True:
 print(counter)
 counter += 1
 time.sleep(1)
 
except KeyboardInterrupt:
 print('Goodbye!')
def main():
 try:
 counter = 0
 while True:
 print(counter)
 counter += 1
 time.sleep(1)
 
 except KeyboardInterrupt:
 print('Goodbye!') 
 sys.exit()