write result to file and db