Question about .chomp with regards to reading in lines for .txt files



How would one read in a line(from lets say a .txt file) using"file.txt").each..... but without taking in the whole line? Is there a .chomp method for files?


Each line in the text file ends with a newline character ("\n" == LF). chomp removes that character.


And where would I add my .chomp method to"file.txt") ?


Inside the .each do loop:

___.each do |line|
    print line.chomp

This isn't tested. Please provide a link to the exercise so we can see what is asked for and test the code. Thank you.


Awesome thanks that's exactly what I needed!
I simply used it for"to_do_list.txt").each do |line|