fixed writing per line to db