Added writePlugin function