modified the method for saving the file to add the extension at the end of the file if it does not already contain it