adding try catch for file clean up