better solution for reading from stdin