Skip to content

Instantly share code, notes, and snippets.

@ukitazume
Last active October 2, 2015 10:08
Show Gist options
  • Select an option

  • Save ukitazume/2225586 to your computer and use it in GitHub Desktop.

Select an option

Save ukitazume/2225586 to your computer and use it in GitHub Desktop.
file = File.read(name)
first_line = File.open(name, &:readline)
File.open(name, 'w') do |f|
f.puts(insert_line) if first_line.chomp != insert_line.chomp
f.puts(file)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment