Guest User

Untitled

a guest
May 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. File.foreach("testfile").with_index do |line, index|
  2. puts "#{index}: #{line}" if line =~ /in/
  3. end
  4.  
  5. fileout = File.new("outfile","w")
  6.  
  7. File.open("testfile", "r") do |file|
  8. file.each_line do |line|
  9. fileout.puts line
  10. end
  11. end # << file automatically closed here
  12.  
  13. fileout.close
Add Comment
Please, Sign In to add comment