This is because your code is directly overwriting it.
For non-existent data points, adding them should be expected to be successful.
If you are trying to add additional information to a data point, you need to first read what is in the data field, capture it, then append the additional data to that capture and then write it back.
Yet, you need to show more of your code and the results of what is said happening, otherwise it’s left to assumption. You can even create a screen capture (.gif/.jpg) and post here as per the forums guidelines. It’s kind of difficult to imagine that what you state should be happening. Unless you target a data point, it should not be impacted.
Also, before making change to critical data points, it should be tested, to determine what is planned to happen will happen.
You’d do this with conditional statements, like -whatif when using your commands or try/catch, etc., in your code as validation steps.