MATLAB: Fprintf without empty lines

empty linesfileoutputfprintfMATLABtxt

Hi everybody,
I have some trouble with fprintf. I want to save a single line of characters in a txt-file. Later on I want to save another single line (chars again) in the same file. But there should not be any empty lines between nonempty lines in the end.
But in the way I coded my function, fprintf exports three empty lines after each line of chars. Even if I use the control characters '\n' or '\r\n' to start a new line.
Does someone know how to fix this?
Here is my code:
filename_user_AWG = [pwd '\resource\txt\user_AWG.txt'];
output = cell2table(AWG_out_str);
writetable(output, filename_helperfile, 'Delimiter', ';', 'WriteVariableNames', false, 'WriteRowNames', false);
fid = fopen(filename_helperfile, 'r');
tempfilecontent = fread(fid,'*char')';
fclose(fid);
fid = fopen(filename_user_AWG, 'at');
fprintf(fid, '%s', tempfilecontent);
fclose(fid);
Greetings, Stefan

Best Answer

...
fid = fopen(filename_helperfile, 'r');
tempfilecontent = fread(fid,'*char')';
fclose(fid);
fid = fopen(filename_user_AWG, 'at');
fprintf(fid, '%s', tempfilecontent);
Any newline characters in the output file here are simply those echoed from the input content of the input file and that are embedded in the tempfilecontent variable.