Re-direct output from Gosub

I was not aware that one could re-direct output from Gosub, but apparently it can be done;
Code:
@setlocal
@echo off
gosub :writefile >output.txt
type output.txt
del /q output.txt
endlocal
quit

:writefile
echo _4ver   : %_4ver
echo _x64    : %_x64
echo _isodate: %_isodate
return

Posting mainly for my future reference, but others may also be interested.

Joe