fixed buffer and file problem