Fix wrong port reading from config file

If the port would be given in the config file, the script wouldn't be
able to read it, thus, this commit fixes that by casting the string that
is read from the config file into the needed value.

Also introduced a couple of string "format" functions to replace the
modulo string formatting.