Add signal handler function if user wants to exit before file ends