Do you really intend to use variable $hhmmss as part of your file name in the open statement?
For test purposes change that line to use something like "testing.txt" and see what happens. Even if you get an error message always check to see if the file got created. If it did, delete it before the next test.