You did not specify the value for filename. Either you omitted in your post or that is the problem.
I use a csv file in the project. And although there's a red cross, this file is readable.
You could however put the file in an own directory (i.e. res://data) and add a .gdignore file to that.
...but this would mean that the file will not be shown in the godot file manager and I doubt that it'll be included if you export the project. So I'd vote against using .gdignore.
Here's a part of a working code example:
var file = File.new()
var csv = file.get_csv_line ()
if csv != groupname: