If the maze is connected, this will work. However, some mazes aren't completely connected. For example:
Code:-E-----
| |
| --- |
| |B| |
| - - |
| |
-------
If you start at B, you'll never make it to E. You'll just keep going around the inner 'island'.