fixed small bug where didn't write correct # rows