Use the correct sqn column name and write out at the correct time.