adding eos detection to stdin stream