write the result to file