Please see my comments in http://www.mathworks.com/matlabcentral/answers/22289-read-an-input-file-process-it-line-by-line
short summary: feof() never predicts end of file.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!