Check if file is a symlink before doing readlink