function line = fgetl(fid)
%FGETL Read line from file, discard newline character. 
%   LINE = 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
%           line = fgetl(fid);
%           if ~isstr(line), break, end
%           disp(line)
%       end
%       fclose(fid);
%
%   See also FGETS, FOPEN.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 5.8 $  $Date: 1997/11/21 23:35:11 $
%
    if nargin ~= 1
        error ('Wrong number of arguments.')
    end
    if isempty(fopen(fid))
        error ('Invalid file identifier.')
    end
    [line,lt] = fgets(fid);
    if ~isempty(lt)
        line = line(1:end-length(lt));
    end
