Code style: use braces for if, whitespace is free these days, use it. Also, maybe not hardcode 640 here, but read it from the config or somewhere?