count outside the loop
Merge pull request #4 from jeffmagnusson/small_write_cleanup

count outside the loop