write result to file