add write to file and database