in reply to printing to file, which is a variable

First, I'd suggest adding use strict; and use warnings; right after the shebang line. Good debugging tools.

Second, I'd suggest modifying your open statement to be something like:

open(MYFILE,">>",$theTime) || die "Unable to open file '$theFile': $! +\n";

The changes inside the parentheses might not be critical, but the die statement will let you know if there's issues with opening the file. Currently, your code is not letting you know if the file was opened successfully.