Added a check before split().

In order to prevent the code from crashing.