issue 145: there were a few places where our fwrite implementation was not used because of include file ordering