Wrapped the CSV file saving in a transaction