Added code to write to shapefile