title: Reading a text file in verilog HDL
body: <p>I can't read a text file in verilog which contains the following: </p>
  
  <blockquote>
    <p>b05_test.dut.n509 0</p>
  </blockquote>
  
  <p>I'm blocked at the fgets instruction <code>scan_faults = $fgets(file_faults , string , data);</code>  because it doesn't work and i tried with fsancf without any positive results.</p>
  
  <p>Any help please? </p>
  
  <hr>
  
  <p>Full Code:</p>
  
  <pre><code>integer file_faults;
  integer scan_faults;
  wire data;
  
  initial begin
    file_faults = $fopen("faults.txt", "r");
    if (file_faults == 0) begin
      $display("data_file handle was NULL");
      $finish;
    end
  end
  
  always @(* ) begin
    if (!$feof(file_faults)) begin
      scan_faults = $fgets(file_faults , data);
    end
    else begin
      $finish;
      $fclose(file_faults);
    end
  end
  </code></pre>