% Counts the lines in the IONEX header.

function NoHL = CalcNumOfHeaderLines(IONEXFile)

i = 0; NoHL = 0;
DataFile = fopen(IONEXFile,'r');
fseek(DataFile, 0, 'bof'); 

tline = fgetl(DataFile); 
while ischar(tline)
    %disp(tline)
    k = findstr(tline, 'END OF HEADER');
    tline = fgetl(DataFile); i = i+1;
    if ~(isempty(k)), NoHL = i;
    end
end

fclose(DataFile);