write to file and refine fields written