in reply to Split on a new line

Without having looked further: don't use an asterisk * in a regex where you mean a plus +. You don't want to split at the empty substring.