File writing

In reply to dave_59:

Hi Dave, fd1 takes up an integer value -2147483645.
Apparently, I got it working by changing the code to

always @ (posedge clk)
  begin
    if(dut_wvalid)
      begin
        fd1 = $fopen("axi_write.txt","a"); //Opening file for write
        $fwrite(fd1,"%h %h \n",awaddr,wdata);
        $fclose(fd1);
      end
  end

But would like to know why it didn’t work in the previous case