fix bug caused by assuming trailing slash for directory as input file