accept input from file when filename is provided otherwise read from
stdin