title: write on file from serial in python in windows
body: <p>I trying to have a very simple script to read data from serial port and write it on a txt file. My data are always the same and for example look like this : '4\r\n'</p>
  
  <pre><code>import serial
  import time
  ser = serial.Serial('COM5', 9600, timeout=0) 
  
  while 1:
     data=ser.readline()
     print data
     f = open('myfile.txt','w') 
     data=str(data)
     f.write(data)
     f.close()
     time.sleep(1) 
  </code></pre>
  
  <p>I am using python2.7 on windows 7
  my print work fine I get the data, but I couldn't write on file... </p>
  
  <p>thanks a lot !</p>