%% Find Current Position in File
% When you open a file, MATLAB® creates a pointer to indicate the current position within the file. Open the following badpoem.txt file and perform a read operation (which advances the position pointer). Then, query the final position in the file after the read operation.
%
%
% Use fopen to open the file. Then, use ftell to query the current position.

fid = fopen('badpoem.txt');
ftell(fid)

% Using fgetl, read the first line and examine the current position after the read operation.

tline1 = fgetl(fid)  % read the first line 
ftell(fid)

% Read the second line and examine the current position.

tline2 = fgetl(fid)  % read the second line 
ftell(fid)

% Close the file.

fclose(fid);

% Copyright 2006 The MathWorks, Inc.