doug's suggestion to look for \n is doubly important because your code has both ends of the pipe open in both processes and thus you won't get end of file. the rule is that in the process that does the writing should close the reading end of teh pipe and vice versa.