Dunfermline dropped back into the Championship relegation play-off place after Hamilton Academical leapfrogged them with a win at East End Park.