How should this piece of code be triggered? From command line? Which tool? Though PKCS#11?

How will the user know that he first needs to delete before it is possible to write? (and how will it be different from "technical problems of actually writing" ?)