Fixed error when piping to less and closing less before end was reached