Read and print string using while loop