workaround for NPE in writeData() (#1019) 

The NPE occurs when one of the items in the 'values' List is null.