Minor fixes
Add requirements.txt and fix syntax error which happens when the tracker
cannot be reached.
Modify flushing strategy
Instead of flushing when the entire torrent has been downloaded, flush after
each write.  This will eliminate loss of received pieces on premature
termination of the program.