modified export.rb to write out file successfully