import java.io.*;

/**
 * A filter which expands tabs
 * <pre>
 *    This is what Java-ized C++ can look like
 * </pre>
 *
 * @version 1.2 04/18/98
 * @author sfb
 * @see java.io.System
 *
 */
public class Tabs
{
	static final private int TABSTOP = 8;
	private int position;
	
	public Tabs() { position = 0; }

	private int findstop() {
		int increment = TABSTOP - (position % TABSTOP);
		position += increment;
		return increment;
	}

	public void filter ( InputStream in, OutputStream out ) throws IOException {
		int c;
		int increment;

		while ( (c = in.read()) >= 0  )
			switch ( c )
			{
			// c is a tab
			case '\t':
				increment = findstop();
				//position += increment;
				for ( ; increment > 0; increment-- )
					out.write ( ' ' );
				break;
			// c is a newline
			case '\n':
				out.write ( c );
				position = 0;
				break;
			// c is anything else
			default:
				out.write ( c );
				position++;
				break;
			}
	}

	public static void main ( String av[] ) {
		try {
			Tabs t = new Tabs();
			t.filter ( System.in, System.out );
		}
		catch ( Exception e) {
			System.err.println ( "exception: " + e.getMessage() );
			e.printStackTrace();
		}
	}
}

