You just have one too many closing brackets. You may be getting misled by the indentation.
#Config Variables
$CSVFile = "C:\Users\\Downloads\Test.csv"
#Get the data from CSV file
$CSVFile = Import-CSV $CSVFilePath
#Read CSV file and Grant Permission to the Folder
ForEach($Row in $CSVFile)
{
$SiteURL=$Row.SiteURL
#Connect to the site
Connect-PnPOnline -Url $SiteURL -Interactive
Try {
#Get the user
$Users = $Row.user
ForEach($User in $Users)
{
#Grant Permission to the Folder
Set-PnPList -Identity $Row.library -BreakRoleInheritance -CopyRoleAssignments
Set-PnPListPermission -Identity $Row.library -AddRole $Row.permission -User $User
Set-PnPListPermission -Identity $Row.library -AddRole $Row.permission -User $User
}
}
Catch {
Write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
}
Catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}