added a proper way of sending files to the output buffer