#!/usr/bin/python
import os
import sys
import json
import getpass
import tempfile
import subprocess
import aesjsonfile

def editfile(fn, password):
    db = aesjsonfile.load(fn, password)
    f = tempfile.NamedTemporaryFile()
    json.dump(db, f, indent=2)
    f.flush()
    while True:
        subprocess.call([os.getenv("EDITOR") or "editor", f.name])
        try:
            f.seek(0)
            db = json.load(f)
            aesjsonfile.dump(fn, db, password)
            break
        except Exception, e:
            print "Error in json"
            print e
            print "Try again (y/n)? ",
            input = sys.stdin.readline()
            if not input.lower().startswith("y"):
                break
    f.seek(0,2)
    len = f.tell()
    print len
    f.seek(0)
    f.write(" " * len)
    f.flush()
    f.close()

if __name__ == "__main__":
    if len(sys.argv) < 2:
        sys.exit(1)
    fn = sys.argv[1]
    password = getpass.getpass()
    editfile(fn, password)

@@ -623,26 +623,17 @@
 t = 
-sys.stdin.readline
+raw_input
 ()%0A 
@@ -742,22 +742,8 @@
 l()%0A
-    print len%0A
     

Clean up input and output.