Update main.c

Added the already implied checking for array termination for the for loop