fixing bad logic bug when checking file existence, readability,
writability