Fixed a bug that wrote an extra row