I don't know what your code is doing, as you have not shown how you created the array you're referencing.
But if you're trying to do random-access i/o on a file, you can't. That's not how buffered file i/o works.
You'll need to work around the problem. Read the entire file into an array, then close the file. Modify the appropriate line. Implode the array and write the resulting string back to the original filename, overwriting the entire file.