pipe read loop