added file writable checking to only apply security permissions if required