clear; clc;

f_out = fopen('test.txt', 'w');
fprintf(f_out, 'Hello, Matlab.');
fclose(f_out);

f_in = fopen('test.txt'); % 'r' by default
while ~feof(f_in)
    disp(fgetl(f_in));
end
fclose(f_in);