Cleaned up flipLine function and made it use a StringBuffer rather than string concatenation