Add functonality to write the output to test.txt file.