The problem seems to be on the following lines:

...edited by moderator

So whenever the user click the cancel button the program will show the error message and then it exit.

My first post...