Check if file is NULL before reading it