Fixed script output and chmod issues