Testing for write permission is done by rc write redirection (echo >.tmp). If it fails then commands intended for such condition will not be executed. Use touch(1) for that test instead.