Reputation: 993
I want to read the input file, line by line, then modify one line and write back the changes to the same file
the problem is that, after writing back, I lose the return to the line and I have all the data in one line
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))
Upvotes: 1
Views: 3827
Reputation: 7361
EDIT
Ok, what was missing is the for loop.
with open(bludescFilePath, 'w') as blu:
for line in blu_file_in_lines:
blu.write(str(line))
Upvotes: 3