bug fix last row doesn't write.