My Question is to capitalise the first word of a string in hacker rank and I am getting an error regarding the EOF error : You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised correctly as Alison Heck.

I had tried in online compiler like repl.it I am getting correct answer but  am getting when I am trying in hacker rank.

flag = True
while(flag):
    try:
        S = input()
        g = (S.title())
        print(g)
    except EOFError:
        flag = False

Traceback (most recent call last):
  File "solution.py", line 26, in <module>
    s = input()
EOFError: EOF when reading a line

