It's better to use 
```
with open(path+":"+key, "w") as f:
    f.write(value)
```