Fixed bug that skipped writing the first line