Added an explicit break inside the main record loop if :ks_next is null.