write to file using model not view