in reply to cgi->vars() unexpected results

This won't solve the problem you're faced with right now but I note that you neglected to lock the file being written to. Simultaneous requests can corrupt your log.