MATLAB: Append data…it doesnt change line

append data.change line

i want to open the 33.txt go to the end of the file add the number 4 ,change line and etc etc…
clc
for k=1:1:5;
fid=fopen('C:\Users\Mr Andrew\Desktop\33.txt','a');
fprintf(fid,'4 \n')
end
what is my error ? my code doesnt change line… thank you

Best Answer

try adding a carriage return as well:
fprintf(fid,'4 \r\n')
I'd also recommend using fclose(fid) each time you've finished with the file