Changed is_file to use stat function