write data to file and in service