I would highly recommend the purchase of an uninterruptible power supply. Depending on your needs, they are VERY inexpensive these days, and in the above situation, you would have not experienced any file loss if you were actually in the process of saving the file.
A UPS will allow you to save all open work files and then perform an orderly shutdown assuming the power failure was more than just a temporary blink in the power. They are well work the small investment.
Secondly, as a previous poster has mentioned, turning on automatic backup is crucial, as well....who hasn't experienced a child or a pet "accidentally" turning off your computer?
Jim...