Null ptr when writing ice to file