check filename defined before checking if it exists