function ok = writefile( filename, contents )
%ok = writefile( filename, contents )
%   Write a string to a named file.  Returns true on success, false on
%   failure.

    fid = fopen( filename, 'w' );
    ok = fid ~= -1;
    if ok
        fwrite( fid, contents );
        ok = fclose( fid ) ~= -1;
    end
end
