writecnt optimization

Reduced file write times by several orders of magnitude by replacing a
looped call to fwrite with reshape coupled with fwrite.