Removing file extension from name. Added error handling.