change the file writing method and format