Add error message when the file format is wrong.

Fix bug where sorting doesn't work on simulation restart.