My car just stops while driving then it will start again and stop again then run on 2001 Kia Optima

i have replaced fuel filter

Asked by for the 2001 Kia Optima
Check engine light on when it is running?
yes,it will come on then go off then come back on.
Ok, there are trouble codes stored in the computers memory, go to Advance or Auto Zone and have the codes read and post the code numbers and we can advise.
codes are P0171 and P0335
Have the Crankshaft Position Sensor checked/replaced, not DIY repair, behind timing belt cover, i think! May also have a vacuum leak.
Had those checked already, i am at a loss. The engine light went out today so I will see how long thst lasts. Thank you
Checked how? By whom?? Google OBDII troble codes and check out PO335! Good luck with it.