Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File.foreach("testfile").with_index do |line, index|
- puts "#{index}: #{line}" if line =~ /in/
- end
- fileout = File.new("outfile","w")
- File.open("testfile", "r") do |file|
- file.each_line do |line|
- fileout.puts line
- end
- end # << file automatically closed here
- fileout.close
Add Comment
Please, Sign In to add comment