Print connects and disconnects properly and die when stdin is closed