Added code to reset file attributes as well while deleting.
Added some comments and exception handling