Probably your second total energy is from the unoptimized structure. My guess is you did
config = nlread("file.nc", BulkConfiguration)[0]
total_energy = TotalEnergy(config)
where file.nc is the output file from the optimization run. It should be
config = nlread("file.nc", BulkConfiguration)[-1]
total_energy = TotalEnergy(config)
because in that NC file, the first config [ 0 ] is the unoptimized structure, the second one [1] is the optimized one. The notation [-1] mean the LAST object, which is most likely the optimized (if you ran several times the same script, with different settings, you may have more than 2 objects in the file).