Check file first, then take input