title: Python read lines from input file and write back to the file
body: <p>I want to read the input file, line by line, then modify one line and write back the changes to the same file</p>
  
  <p>the problem is that, after writing back, I lose the return to the line and I have all the data in one line</p>
  
  <pre><code>open(bludescFilePath, 'a+') as blu:
  
  blu_file_in_lines = blu.readlines()
  
  for line in blu_file_in_lines:
                      if "Length" in line:
                          blu_file_in_lines[13] = line.replace("0x8000",str(size))
  
   with open(bludescFilePath, 'w') as blu:
                  blu.write(str(blu_file_in_lines))
  </code></pre>