title: Writing data from a sensor to a file
body: <p>I am trying to write data from a sensor to a .txt file in a loop that takes the readings every 30 seconds, but currently its not taking readings from the sensor (or its not writing them to the right place) </p>
  
  <p>I have a <code>while(True)</code> loop as:</p>
  
  <pre><code>f = open('/home/pi/sensor_data.txt','a')
  while True:
      humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
      data = humidity, temperature
      textdata = str(data)
      f.write('textdata\n')
      time.sleep(30)
  
  f.close()
  </code></pre>
  
  <p>this wants to take readings from the sensor every 30 seconds and write it to the file sensor_data. Currently its only writing 'textdata' to the file, how do I go about writing actual data from the sensor to it? I am very new to programming</p>