title: Error reading local file in Sinatra
body: <p>I'm trying to write a Sinatra app that reads in a list from a file, and then spits back a random item from that list. </p>
  
  <p>I'm having trouble figuring out the path to the file to read it, though. Sinatra says 'no such file or directory' when I try to load an item in my browser:</p>
  
  <pre><code>Errno::ENOENT at /wod
  No such file or directory - http://localhost:4567/listing.txt
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>require 'sinatra'
  
  @list
  
  get /item
    puts read_list[rand(@list.size)]
  end
  
  def read_list
    File.open('listing.txt', 'r').readlines
  end
  </code></pre>
  
  <p>I have the file in <code>/public</code>, which the Sinatra README says is the default location for hosting static files. Furthermore, if I put it in <code>/public</code> I can navigate to <code>localhost:4567/listing.txt</code> and read the file in the browser. </p>