Text File Writing at Incorrect Line After Being Read

Updated Apr 26, 2018

Reported In


  • LabVIEW

Issue Details

I'm reading in the first three lines of a text file using Read from Text File VI and passing the refnum output to Write to Text File VI to overwrite my file with new data. Whenever I do this, my file keeps the first three lines and appends the new data after it. Why is my code doing this?


Since the file was read up to the third line, the current file position will be there as well. Passing the refnum out from the Read from Text File VI to the Write to Text File VI causes the new data to be written at line 3 like the example below.

Wiring in the original file path will overwrite the file with the new data starting from the beginning of the file. The example below demonstrates this implementation.


Additional Information

The Set File Position VI can be used to write the new data in the beginning of the file using the refnum out from the Read from Text File VI. However, doing this will not completely overwrite the text file, but instead replace the lines that the new data will occupy, while keeping the rest of the original data intact.


Not Helpful