Writing to a .txt file was a bad idea, I think it'll be easier to just go straight into the .db, even though the learning curve may be higher...