Added error checking to the file dialogs