Move chmod to try catch block