when updating data.json, truncate file after reading and before writing again, or we otherwise might end up with broken json