title: python 3.2: IOError: [Errno 22] Invalid argument: '/home/pi/data/temp/file1\n.txt'
body: <p>I am a newbie to python programming. I have a counter.txt file from which i am reading the counter value . Using this counter value, i have to create new files into some other folder like '/home/pi/data/temp/file%s.txt'%line.
  for eg: file1.txt, file2.txt and so on..</p>
  
  <p>I have written some code for this and for some reason i am encountering the error below: </p>
  
  <pre><code>IOError: [Errno 22] Invalid argument: '/home/pi/data/temp/file1\n.txt'
  </code></pre>
  
  <p>My python code is as follows:</p>
  
  <pre><code>while True:
  
      counter_file = open("counter.txt", 'r+')
      line = counter_file.readline()
      print(line)
      counter_file.close()
      file_read = open(r'/home/pi/data/temp/file%s.txt'%line, 'w')
      #data_line = line_read.decode("utf-8")
      #file_read.write("%s"%data_line)
      file_read.close()
      counter_file = open("counter.txt", 'w')
      line = int(line) + 1
      counter_file.write("%s"%line)
      counter_file.truncate()
      counter_file.close()
  </code></pre>
  
  <p>while i execute this, i get this traceback:</p>
  
  <pre><code> File "compute1.py", line 24, in &lt;module&gt;
      file_read = open(r'/home/pi/data/temp/file%s.txt'%line, 'w')
  IOError: [Errno 22] Invalid argument: '/home/pi/data/temp/file1\n.txt'
  </code></pre>
  
  <p>Please help me in this regard. 
  Thanks! </p>