added a main method that reads from stdin until EOF