title: Can't see the output of a function is equal to a string
body: <p>I have a program that whenever I press a button it writes a value to a text file. The next time the button is pressed it finds the string that was written last and calls the variable to do the opposite. This continuously is running until I shut it off. My issue is it doesn't stop printing &quot;Off&quot;, which is the last string in my text file. When the program runs, Fine() prints the last string of the text file then it goes into the while loop. It doesn't seem to recognize my if statements and just prints Fine() again without change. I don't know why it keeps printing &quot;Off&quot; it could be a formating thing that I don't know of, but I've looked and couldn't find anything similar to it.</p>
  <pre><code>import time
  import os
  # this is the system that detects the last line. In order to seek the end of file, we have to open the file in binary mode. We seek the last 2 characters
  # since the file is likely to end with a newline. Then, keep reading a single byte until a newline character is found. And, finally, we use readline() to read the \
  # final line, and decode() to convert from bytes to string.
  
  
  # Checker is a fall back system so if there is nothing in the file then it writes on(or the terms i am using at that time.) so that when I press the button again it starts the cycle.
  
  def Checker():
      file = open(&quot;Store.txt&quot;).readlines()
      #print(file[0:2])
      if file[0:2] != ['On\n', 'Off']:
          print(&quot;nothing is here...Restarting file with added Off&quot;)
          with open(&quot;Store.txt&quot;,&quot;w&quot;) as df:
              df.write(&quot;On\nOff&quot;)
              df.close()
      
  def Fine():
      with open(&quot;Store.txt&quot;, &quot;rb&quot;) as f:
          f.seek(-2, os.SEEK_END)
          while f.read(1) != b'\n':
              f.seek(-2, os.SEEK_CUR) 
          print(f.readline().decode())
  
  
  def w_on():
      print(&quot;The light is on&quot;)
      with open(&quot;Store.txt&quot;, &quot;w&quot;) as on:
          on.write(&quot;On\n&quot;,&quot;On&quot;)
          on.close()
  
  
  def w_off():
      print(&quot;this is off&quot;)
      with open (&quot;Store.txt&quot;, &quot;w&quot;) as off:
          off.write(&quot;off\no&quot;,&quot;OFFF&quot;)
          off.close()
      
  
  
  #This checks the status of the text file and corrects it if the text inside is wrong.
  Checker()
  # this prints the current last line in the Store.txt file.
  Fine()
  
  
  #============================================================================================
  #Here is the start of my Issue of it printing &quot;Off&quot;
  
  # 1==1 replaces the button.pressed() function    
  while True:
      time.sleep(1)
      if 1==1:
          if Fine()==(&quot;On&quot;):
              # the print function replaces the function for the servo moving. right here the off funtion would happen.
              print(&quot;The light is turning off&quot;)
              w_off()
  
          elif Fine()== (&quot;Off&quot;):
              # the print fucntion replaces the function for the serveo moving. right below, the on funtion would happen.
              print(&quot;The light is turning on&quot;)
              w_on()
  
  
      time.sleep(2)
             
                  
                  
                  
       
  </code></pre>