function fid = OpenCaseFile(fname, fields)

% fid = OpenCaseFile(fname, Fields)
%
% Fields is a string with all the field names

% open text file for writing
fid = fopen(fname,'wt');

% write NETICA header text
fprintf(fid,'// ~->[CASE-1]->~\n\n');

%write field names
fprintf(fid,'%s\n',fields);
