title: Replacing first character in file Python 2.7
body: <p>I'm trying to replace the first character in a file so that I end up with either a <code>1</code> or a <code>0</code> in it. Here's my code:</p>
  
  <pre><code>import os
  
  hostName = raw_input("IP: ")
  communicate = open("communicate.txt", "w")
  
  while True:
      response = os.system("ping " + hostName + " -c 1")
      if response == 0:
          # Replace first character with '1'
      else:
          # Replace first character with '0'
  </code></pre>
  
  <p>I am running the code in a Linux virtual machine through the terminal.</p>