Bug fix - ordering of items in writefile