title: Trouble outputting data to local file
body: <p>I've been teaching myself Ruby and I'm quite stuck trying to output information to a text file. The file is created, there are no errors thrown, but nothing is being written to the file. I've chosen to amend the file vs. writing to it, as I don't want the data to be overwritten. I know this will be a simple answer but I've been beating my head against a wall for a while now. Thanks in advance.</p>
  
  <p>Here's my controller</p>
  
  <pre><code>class EntriesController &lt; InheritedResources::Base
     actions :new, :show, :index, :edit, :update
     before_filter :set_message, :only =&gt; [:update]
  
     def save_to_file
      playlist = 'playlist.txt'
      File.open(playlist, 'a+') do |entry|
        entry.each do |entry|
          f.puts '#{entry.song}  by  #{entry.artist}  on  #{entry.album}'
        end
      end
    end
  
    def create
      @entry = Entry.new(entry_params)
      if @entry.save
        flash[:notice] = "Your song was added"
        save_to_file
        redirect_to entries_path
       else
        flash[:error] = "Your song wasn't added. Please check all info and try agian."
        render :new
      end
    end
  
    private
    def entry_params
      params.require(:entry).permit(:artist, :album, :song)
    end
  
    def set_message
      flash[:warning] = "Are you sure you want to overwrite this song information?"
    end
  end
  </code></pre>