Correct Port::location

- initialize local variable i to 0
- use String::charAt instead of indexing for ES3 compatibility