Im trying to write a program that reverses the order of values in an input file using a stack and saves the result to a file
<pre><code>def main():
fname = input("Please input file name: ")
   # open input file 
fin = open(fname, "r")

   # open output file
fout = open("output.txt", "w")

for line in fin:
    token = Stack()
    if token:
        token.pop()
        fout.write(items)
    fout.write("\n")
fin.close()
fout.close()    
</code></pre>

<p>Assuming the input file contains a single value per line. 
My error message reads: pop from empty list
Im sure my problem is not getting the values from the input file and putting them in to a stack.</p>

<p>Instead of <code>if token:</code> try using <code>if !token.isEmpty():</code></p>

python python-3.x