Hey cosplay, the only way to get that message ("Ignoring protected file") should be if the layer count happens to be stored as a value >= 10000, so maybe something went wrong there? (I use that as a special way to identify .xp files for my own use with a different version of RP.)
It looks like you're indeed saving it as 1 by default there with "buf.putInt(1) // Only 1 layer", but I dunno, maybe the actual file output is not quite what you intended.
If you want you can attach your .xp file here and I can look at it, but that'd be what to check first.