function lc = line_count ( filename )

%*****************************************************************************80
%
%% line_count() counts the lines in a file.
%
%  Modified:
%
%    29 November 2018
%
%  Modifier:
%
%    John Burkardt
%
%  Author:
%
%    Matthew Dailey, 2000
%
%  Input:
%
%    string filename, the name of the file.
%
%  Output:
%
%    integer lc, the number of lines.
%
  fid = fopen ( filename, 'r' );

  lc = 0;

  if ( fid < 0 )
    return
  end

  while ( true )
    ln = fgetl ( fid );
    if ( ~ ischar ( ln ) ) 
      break; 
    end
    lc = lc + 1;
  end

  fclose ( fid );

  return
end
