Im writing a script which reads input file, takes the value and needs to write in the specific place (line) in output template, I'm absolute rookie, can't do it. It either writes in the first line of the output or in the last one.
opened file as 'r+'
used file.write(xyz) command
Confudes about how to explain to python to write to specific line, eg. line 17 (which is blank line in output template)
edit:
with open (MCNP_input, 'r+') as M:
line_to_replace = 17
lines = M.readlines()
if len(lines) > int (line_to_replace):
lines[line_to_replace] = shape_sphere + radius + '\n'
M.writelines(lines)