grep file output not saved until code completion

In my code i have a sequence of grep commands:

grep wave as file

later followed by

grep file as wave

This doesn't work as expected because the file output from grep doesn't seem to be marked as saved or updated until the code is completed. That is, the second grep operates on the file as it was before the first grep supposedly overwrote it.

How can I persuade the OS to save the file immediately after the first grep?

Following

grep wave as file

with

open /A refnum as file; close refnum

seems to do the trick. Is that the best solution?

What you are describing doesn't make a lot of sense. If you can provide an example that we can execute that reproduces this behavior, we could investigate. Feel free to send to support directly. Also, we need to know your system information (Help->System Information).

I haven't been able to reproduce this behaviour, so either I or my computer was acting strangely on Monday...