added rob's patch for infinite write loop