Only write when there are changes