Center of gravity calculator using file i/o