bugfix write_integral (forgot to change the very first call)