<p>Such as deleting the output file during run, directing two instances of the sw to the same IO etc ?</p>

There isn't much you can do to prevent the user from doing that, but what you can do is to apply
defensive programming
.
In your two examples you'd have to, every time you access a resource, detect failure conditions and react appropriately either throwing exceptions and dying or continuing without access to that resource.
Never assume a resource allocation will succeed, always check what you don't control. In short,
assume as little as possible and verify everything
.
'I'm told to access this file to write to it. Is it already open? Do I have permissions? Does it have the expected format? Does the disk have enough space? etc.'
There is many more about this. Just Google for defensive programming and you'll get a lot to read about.