input file scanning modified so that it is idiot-safe