Good day.

Maybe someone has a sketch to replace the last line in the file - in a loop. Those. sort of

While(True) { заменяем последнюю строку; if($s == false) exit(''); } 
  • one
    why cycle? - jkeks
  • This is an example of use. In order to output the latest data to a file, let's say the loop counter, so that there is no such porridge as "1,2,3,4" and this figure has always been replaced by the latter. Here is an idea. - xenoll
  • one
    @xenoll Button 101010 in the editor formats the code. - Nicolas Chabanovsky

1 answer 1

Change the last line ... For what?

Get the buffer variable. Read the first line there. Then cycle in rows (from the second to the end). In the loop, output the buffer variable and put the next line there. After exiting the loop in the buffer, you have the last line. Replace it with what you need and output. If the file is empty, break off on first reading.