added same functionality for cp and selfService as well
handled the NoSuchFileException when closing