check if the file exists before changing permission. need a better approach