NESTED PROCEDURE... Now I can write to outfile without the handle