Adding permission handling to file creation