Adding trace file writing