Fix Write did not set count corretly