Try this example: https://decibel.ni.com/content/docs/DOC-25163
As an aside, in why are you reading the whole file into an array? Why not use file.readline() and file.writeline()?
As far as i know you can not edit a line in the middle of the file. Have to read the whole file with file.readline() any way.
You can edit parts of a file without reading the entire file. However, you can only change the characters in the file; you cannot insert new characters in the middle or delete existing characters without reading and rewriting everything past the point where you are making changes. To go to a specific location in a file, use the Set File Position function in the File IO->Advanced File Functions palette. The next read or write will start at that file position, so to make changes in the middle of a file you need only to move to the right file position and start writing, which will overwrite the existing data from that location.