UVM is designed so that you can use a scoreboard/comparitor to do transactional checking while your test is in progress. This allows better debug as you can easier pinpoint when your errors occur.
If you want to do file compare, you probably want to do it in the check_phase() when all data is written to your files instead of the run_phase() while the files are being written.
One thing to add here why this did not work is that a “fork” in SystemVerilog does not create a background process on the host OS running the simulation. Process threads of activity in SystemVerilog are completely independent concepts from what happens in a multi-program operating system. The call to $system acts as a function call that returns in 0 simulation time.