Script now closes connection after writing row.