input: Write a Python class to read in a textfile and count the frequency of each word. The class should automatically process the file upon initialization and provide a method to retrieve 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
  
  assert WordCounter('example.txt').get_word_counts() == {'example': 3, 'text': 2}
  assert WordCounter('empty.txt').get_word_counts() == {}
  assert WordCounter('single_word.txt').get_word_counts() == {'hello': 5}
output: 
  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
  