Check dirname presence

I get a notice error calling method read without parameter.