Once you have called the print command, to output something, you can't undo that, or take it back. So what you would need to to is not print at that point, but just save all the stuff to be printed until the end of the processing, and then do it.
If you posted your script, and where exactly the problem is, we could be more specific with answers.
C.