function tline = fgetl(fid)
%FGETL Read line from file, discard newline character. 
%   TLINE = FGETL(FID) returns the next line of a file associated with file
%   identifier FID as a MATLAB string. The line terminator is NOT
%   included. Use FGETS to get the next line with the line terminator
%   INCLUDED. If just an end-of-file is encountered then -1 is returned.
%
%   FGETL is intended for use with text files only.  Given a binary file
%   with no newline characters, FGETL may take a long time to execute.
%
%   Example
%       fid=fopen('fgetl.m');
%       while 1
%           tline = fgetl(fid);
%           if ~ischar(tline), break, end
%           disp(tline)
%       end
%       fclose(fid);
%
%   See also FGETS, FOPEN.

%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 5.13 $  $Date: 2000/08/07 15:16:46 $
%
    if nargin ~= 1
        error ('Wrong number of arguments.')
    end
    if isempty(fopen(fid))
        error ('Invalid file identifier.')
    end
    [tline,lt] = fgets(fid);
    if ~isempty(lt)
        tline = tline(1:end-length(lt));
	if isempty(tline), tline = ''; end
    end
