Fix for #388 handle that the file object could be null (since the function being called can return a null)