title: How do I read from a text file and create instances of classes with the lines of text to put them into an array?
body: <p>I have a text file, named "test.txt", that reads exactly as follows:</p>
  
  <pre><code>Hello world
  Cat and dog
  It is hot outside
  </code></pre>
  
  <p>And in my code, I'm trying to read the line of text from the file and create an instance of the "Object" class with the sentence that I just read. I know how to do it without using instances of classes, but for the purpose of a larger project that I'm working on, I'm trying to understand how to read lines from a file, create an instance of a class with the read line, and then create an array of the class instances. Am I on the right track?</p>
  
  <pre><code>class Object
    attr_accessor :str
  
    def initialize(sent)
      @str = sent
    end
  end
  
  class Solution
    attr_accessor :array
  
    def initialize
      @array = Array.new
    end
  
    def make_Array
      File.open("test.txt").each do | line |
        @array &lt;&lt; Object.new(line.chomp)
      end
      print @array
    end
  end
  </code></pre>
  
  <p>I also kept seeing a warning message that mentioned Object being instantiated and an infinite loop, could someone explain to me what that means? </p>