rewrite the file