function save_timesexecuted(varargin)

% will create a single text file with name batch_name_timesexecuted
% containing number of times each reaction executed for specific set
% and run number   in the same way as stand-alone version
%                                        Slava Chushak      02/07

% 1st argument = file ID
% 2nd argument = rxn_grp_ID
% 3rd argument = set_id
% 4th argument = run_id
% 5th argument = rxn_grp{i}.times_rxns_executed to be saved


fid = varargin{1};
n_rxn = length(varargin{5});
timesexecuted = varargin{5};

fprintf(fid,'grp %d rxns %d\n',varargin{2},n_rxn);
fprintf(fid,'set %d run %d\n',varargin{3},varargin{4});

for i=1:n_rxn
    fprintf(fid,'%d %d\n',i,timesexecuted(i));
end