fixed problem with undefined elements in array
Get defensive about opening files which may not exist.