"buffered output working, except one bug in the beginning of pattern"