Am I safe to assume you are trying to write a record back to the main window like an error message? And when this write is happening all tho open windows are closing ? I would ask what is triggering this line of code you want to write and why the results would not show in the same location. If this is an error condition for the open window, why not show it in the open window on the last line of the window?
If this is not the case a little more info would be nice.