stats: Changed write_rows to a nested array