Why does FEOF return false when opening an empty text file in MATLAB?
Show older comments
I am using the following code to read a text file line by line. I have noticed that if the file is empty, FEOF returns a 0 and I run through the loop at least one time.
fid = fopen('foo.txt');
while ~feof(fid)
s=fgetl(fid);
% do something with s
end
fclose(fid);
Accepted Answer
More Answers (0)
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!