Implement partial pipe read (like '| head -n x')