input: Write a Python class to read in a text file and count the frequency of each word. The class should have methods to initialize the object with a filename, process the file to count the words, and return the word counts.
  
  class WordCounter:
      def __init__(self, filename):
          self.word_counts = {}
          self.filename = filename
          self.process_file()
  
      def process_file(self):
          with open(self.filename) as f:
              for line in f:
                  words = line.split()
                  for word in words:
                      if word in self.word_counts:
                          self.word_counts[word] += 1
                      else:
                          self.word_counts[word] = 1
  
      def get_word_counts(self):
          return self.word_counts
  
  # Test cases
  counter = WordCounter('sample.txt')
  assert counter.get_word_counts() == {'hello': 2, 'world': 1}
  
  counter = WordCounter('empty.txt')
  assert counter.get_word_counts() == {}
  
  counter = WordCounter('single_word.txt')
  assert counter.get_word_counts() == {'test': 1}
  
  counter = WordCounter('multiple_lines.txt')
  assert counter.get_word_counts() == {'line1': 1, 'line2': 1, 'line3': 1}
output: 
  class WordCounter:
      def __init__(self, filename):
          self.word_counts = {}
          self.filename = filename
          self.process_file()
  
      def process_file(self):
          with open(self.filename) as f:
              for line in f:
                  words = line.split()
                  for word in words:
                      if word in self.word_counts:
                          self.word_counts[word] += 1
                      else:
                          self.word_counts[word] = 1
  
      def get_word_counts(self):
          return self.word_counts
  