I was wondering in this bit of code:

Code:
void Pconnect::WriteToPipe(string s) 
{ 
   DWORD dwWritten; 
   CHAR *chBuf; 
	s += "\r\n";
 
// Read from a file and write its contents to a pipe. 

      if (! WriteFile(hChildStdinWr, s.c_str(), s.size(), 
         &dwWritten, NULL))
		 std::cerr << "Write to pipe failed.\n";
// Close the pipe handle so the child process stops reading. 


   if (! CloseHandle(hChildStdinWr)) 
	  std::cerr << "Close pipe failed.\n";
}
Why is it necessary to close the handle after writing? My child process is a Telnet program and it reads the handle closing as an 'End of File' file command which it sends to the server. The server then stops listening and I can't write anymore. I fixed it by commenting out the last if statement for closing the pipe and it seems to work fine and the pipe still gets closed when my program ends. So is there any reason I should avoid doing this? If so do you have any ideas how?
thanks