Changed while loop to exit on keyboard interrupt