[GIS] append X,Y,Z and intensity values into a las file

laslaspypdalpython

I want to append XYZI values row after row into a las file.How to do this?
I'm using python laspy library to write XYZI points at once, but i want to append row after row using a loop.

The points are in SQLite db I need to generate a .LAS file(v1.3 and v1.4).I get memory error as the db grows large.

i'm doing this

import laspy

header = laspy.header.Header()
outfile = laspy.file.File("output.las", mode="w", header=header)
outfile.X = read column1 from db
outfile.Y = read coulmn2 from db
outfile.Z = read column3 from db

outfile.close()