Implemented for loop to check for possible file types (.*, .gz, or .Z)