only write file if it differs from old file