Fix performance

Don not reload the data file every time, keep it in memory and dump it out.