idGamesFile: issue #150; add commas/closing parenthesis correctly

- Make sure the last element in the SQL doesn't have a comma, and that
  the closing parenthesis is in the right place to make a valid SQL
  statement