Added code to write diamagnetism to file after each bin