Added error trapping and added customized file name