fixed error: now properly creates file and also warns user if they would like to override an existing file if the file name already exists. (slight change, reformatted code and simplified some of it.)