From: Yui NARUSE Date: 2011-03-22T09:30:12+09:00 Subject: [ruby-core:35539] [Ruby 1.9 - Bug #4515][Rejected] File.each_line read all lines of file as one line Issue #4515 has been updated by Yui NARUSE. Status changed from Open to Rejected ---------------------------------------- Bug #4515: File.each_line read all lines of file as one line http://redmine.ruby-lang.org/issues/4515 Author: Yen-Nan Lin Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: - I access a tab-delimited text file from Excel, the text file is 5 lines in my editors (TextEdit, TextWrangler). However, when I use File.each_line to read it, this method only iterate once and combine 5 lines to 1 line. I expect my code to puts count = 5, but it print 1. Below is my code, the test2.txt file is in attachment if you need. ---------------------------------------------------- filePath = "test2.txt" data = Array.new File.open(filePath, 'r') do |f| count = 0 f.each_line do |line| data << line.split.map { |entry| entry.to_i } count += 1 end puts count end ---------------------------------------------------------- I find a solution in http://railsforum.com/viewtopic.php?id=15582 But I think this bug should be solved. Thank you very much!! Yen-Nan Lin -- http://redmine.ruby-lang.org