Fix function call, change permission after file is created