function out = fgetl(fileID)
%MATLAB Code Generation Library Function

%#codegen

%   Copyright 2019-2023 The MathWorks, Inc.
gets = fgets(fileID);
if isempty(gets)
    out = gets;
    return
end

if gets(end) == newline
    if ~isscalar(gets) && gets(end-1) == sprintf('\r')
        out = gets(1:end-2);
    else
        out = gets(1:end-1);
    end
elseif gets(end) == sprintf('\r')
    out = gets(1:end-1);
else
    out = gets;
end
end
