Level Triggering

I wish to know how can level triggering be done in Verilog. I am writing contents to a file and I wish to write at Level-Triggering of the clock but I am unable to implement the level triggering. I thought of the following method :


module tb(input clk,
input[31:0] wdata,
input[31:0] addr
);
integer fd;
initial
begin
fd = $fopen("test.txt","w");
forever 
begin
wait(clk)
begin
$fwrite(fd,wdata);
$fwrite(fd,addr);
end
end
$fclose(fd);
end
endmodule




Can someone tell me whether it is correct or not or suggest any alternate method to implement level-triggering.
Thank you

PS- If this is right method, should there be a semicolon after wait(clk) or not?

In reply to nimesh13:

Your code does not work because as soon as clk goes to 1, you go into an endless forever loop, which executes $fwrite over and over again until you fill up your disk and crash. There is no way the code can ever get to the $fclose statement.

I don’t think of a level as a trigger. A transition from 0 to 1 is a trigger @(posedge clk). Can you explain exactly when you want the write to happen. Best is if you provide a complete runaable example.