Added a check before split().

In order to prevent the code from crashing.
Merge pull request #321 from jesusjzp/master

Added a check before split().