Fixing issue with filemode