write model to file using template