function KeenRLE
{	
	loop while (file.remaining-bytes > 0)
	{		
		read unsigned16 token

		if (token == magic-number)
		{
			read unsigned16 number-of-words
			read unsigned16 word-to-write

			loop (number-of-words)
			{
				write unsigned16 word-to-write
			}			
		}
		else
		{
			write unsigned16 token			
		}
	}
}

function KeenRLEB
{	
	loop while (file.remaining-bytes > 0)
	{		
		read unsigned8 token

		if (token == magic-number)
		{
			read unsigned8 number-of-words
			read unsigned8 word-to-write

			loop (number-of-words)
			{
				write unsigned8 word-to-write
			}			
		}
		else
		{
			write unsigned8 token			
		}
	}
}