code updated to have writing intensities to a file