Now youre reading your file twice, first in the initial run, then also in the second run. This is probably still not what you want to do.
If you want to do something only in the second run when the log file is open, just count the runs. Like this:
int count = 1;
function run()
{
...
if(count == 2) {
buff = ...
...
}
count++;
}
Hope this helps...