The phrase "by a whisker" means something that is accomplished by a very small margin, or almost but not quite. It refers to an extremely close call or narrow escape, where one comes through a difficult situation just by the smallest possible amount of luck or effort. The term originates from horse racing, where a whisker is the thin line of hair on the upper lip of a horse. A photo finish in a race can be determined "by a whisker," meaning that it was won by such a small margin that it could not be seen with the naked eye and had to be measured in millimeters or even thousandths of an inch.