implement fixed-length file recording

as opposed to infinite loop