how to count bytes written and read