json write function; update current page count