Still helpful to post your solutions for people who find your problem in a search
I’m guessing it’s something like “need to test existence of the file before looking for the existence of its content”?
if exists file “tmp/myfile.csve” then exist lines whose ((preceding text of first “,” of it as string as lowercase) is equal to hostname as string as lowercase) of file ("/tmp/myfile.csv") else false
Well the problem hence the solution was not in the syntax, but rather, as I said, a stupid mistake. the filename had an additional character that was a typo. Once fixed, everything worked.