tags:

views:

46

answers:

2

I want to add a new line after a string is inserted.

My current code looks like this:

  File.open(filename, 'a') do |file|
    file.write @string
  end

How could I add a new line after the string is inserted?

+3  A: 

file.write "\n"

Borealid
+1  A: 
file.puts @string

Don't forget to close your files with file.close or feel the wrath that is IO.

Maletor
He's using the block form of IO#open, which will close itself on exit.
guns