fix with check that stdin pipe is open