Added packet write method