in reply to output caught in memory

The easiest way to make sure the write occurs is to write it in two lines - and set your write buffers to instant write.

So try this:
$|=1; # $| is undef by default - which means use buffering - define it + as 1 - and it instantly writes. print FILE scalar localtime; print FILE " ## Exit\n"; close FILE;
Alternatively, you can try to build the entire entry into a variable first - then write it. So:
$close = localtime; print FILE "$close ## Exit\n"; close FILE;
I hope this helps :).

Update: Remove quotes around scalar localtime in first code block (thanks MZSanford)
game(Wookie,opponent) eq 'Wookie' ? undef $problem : remove_limbs(arms,opponent);