Did you actually try this code? It looks like it should work. The only
possible problems would be collisions if more than one process tries to
write to the file. For example if the positive edge of clk coincides
with time 0, you would have a race between the initial block and the
clocked process.
The other thing is that I don't see anything that closes the file, which
would help if you want to look at the file contents before you close the
simulation.
--
Gabor