Now writes energy levels to file.