require "filelock"
require "mailread"


FileLock::LockFile::create_for(ARGV[0]) do |not_ok|
   fp = open(ARGV[0])
   until fp.eof? or not_ok.call
      mail = Mail.new(fp)
      print "From=#{mail.header['From']}, Subj=#{mail.header['Subject']}\n"
      sleep 1
   end
   print "Lock was stolen!\n" if not_ok.call
   fp.close
end
