Your problem is with explode.
Let's say you have this code:
$msg = "1,2";
$arr = explore(',', $msg);
then
$arr[0] == '1'
$arr[1] == '2'
right?
Now, if you have this:
$msg = ",2";
$arr = explore(',', $msg);
then
$arr[0] == ''
$arr[1] == '2'
because you're splitting in the comma, and before the comma there's nothing, so $arr[0] is ''.
Now, in your code, $message becomes this:
$message = "%some stuff\n%some stuff2"
right?
so when you do explode("%", $message), the first element of the array will be empty.
You might want to take a look at the function file():
http://www.php.net/manual/en/function.file.php
Diego