added main (missing file i/o and input validation