Fixed: handling broken pipe