ok so i’m trying to just read out a file line by line and i can’t seem
to figure out how to not get an EOFerror… is there some way to tell
when i get to the end of the file?
i’m just reading out line by line, splitting it and sticking it in a
database.
Hmm, not sure what you are missing, seems fine to me.
irb(main):001:0> f = File.new(‘test.txt’)
=> #<File:test.txt>
irb(main):002:0> f.each_line do |line|
irb(main):003:1* w = line.split(’ ')
irb(main):004:1> puts w
irb(main):005:1> end
First
Second
Third
=> #<File:test.txt>
My file had First, Second and Third on separate lines.