title: Sinatra File deleter
body: <p>I am using sinatra,ruby and MongoDB to export a CSV file from the MongoDB. I am able to create the CSV file and export it.
  I delete the file after exporting it.
  But it gets deleted only after I exit sinatra.
  Can anybody explain why is this? 
  Suppose a file <code>abc****.csv</code> is created.
  I am deleting this file using</p>
  
  <pre><code>file_path = '/home/Test_app';
  file = Tempfile.new([@@uname,'.csv'],file_path);
  file_name = file.path();   
  puts file_name  # gives /home/Test_app/xyz****.csv
  send_file(file_name, :disposition =&gt; 'attachment', :filename =&gt;File.basename(file_name));
  File.delete(file_name); 
  File.unlink(file_name);
  </code></pre>
  
  <p>But it gets deleted only after I exit sinatra server. Can anyone explain please?</p>