Delete script before writing to it

This way we avoid chmod permission errors when the current user is not the script owner.