write_segments now includes previous and next supf

Masks array data at the beginning and end of the parameter.