Refactored filename variable to arg in nextArg()
Added extractPort helper