function tofile(outfile,varargin)
% tofile - Run functions that need a file handle to write output
%
% tofile ::
%    path ~'file name to write to',
%    (fid -> action unit) ~'action taking file handle',
%    (fid -> action unit) ~'action taking file handle',
%    ...
% -> action unit.
%
%	Opens the given file in APPEND mode, then calls each function
%  passing the file handle to each. 


fh=fopen(outfile,'a');

fprintf(fh,'\n%% --- New session ---\n\n');

for i=1:length(varargin)
	fprintf(fh,'\n%% --- Running %s\n\n', func2str(varargin{i}));
	feval(varargin{i},fh);
end

fclose(fh);
