Most likely you do not have write permissions in the current folder. Use a folder with write permissions and absolute file names:
in_file = fopen(fullfile(tempdir, 'name_of_file'), 'wt');
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!