Make write_history not crash on non-streaming jobs

This fixes the issue I pointed out in #224