GEOT-3131 remove unnecessary cycle and sysout

Hi,
A found in Jira this bug, http://jira.codehaus.org/browse/GEOT-3131
I removed unnecessary for loop, and add condition to check if index is not null because null pointer exception may occur. 

Best regards
Martin Tomasek